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 C3276A034F for ; Wed, 10 Nov 2021 07:52:19 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BD33E40683; Wed, 10 Nov 2021 07:52:19 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2085.outbound.protection.outlook.com [40.107.244.85]) by mails.dpdk.org (Postfix) with ESMTP id 8819140142 for ; Wed, 10 Nov 2021 07:52:17 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kz3HtEqVT1CW9OCKC12mH/trDgfc5rT61rP17/BSxxuswn7uHU+J5j3k7CQC86DGPnaFCOIL2KQMM51wQtUfSVfJahRcrCndryeuig3NoXhuToa2QiJvCbuIOzckxpaJ/OSFJ/8D6lLWp4j+4MyJF4ii0bquIRHWL1iUpiPLweW6Rj5ZBld5eJFgxRnN7/TYvweoNRjN1iTwRuk5rJsQ8E0agJkvxwMKwM9bj2pHGbvAJj8PJ2PnFfgVkTSLOLto+d2UO2jFKbDedJh4P52DJ9ES4SeugOYf1N+4BRd8Sdj/sNDoHXeTw4d9AGTDnHtjvqyuRW7P1GxPn4Q1p8q6qg== 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=GiOv6fetb5tJfAtb3nn2oCe7rTw+/dBwnzw7/uYCGn0=; b=Np9n8e4ILkbYxfspXH5y9koCJamHKKLxJFVgDqpDSf5PJnj5z0h16+XYT5871dg7O7XsuWGto+yNbPjIHZ+AFA1GAP0ByBaKKV9d8ZzNZbjPp2OvOUpNQu0IhwDQrpDXIFaaBxfKmbdF8jd8ycLyX74aJN2DWaLnV50ke0qENLDJpPn2GyqKIlNdz+lE3SRUrS9COJRX483Vbm2N75EgYECdU7yx34KqsxrQ5tZT8fefXYynJDngzasmaNCO/eVUN2n8KJY+7RkHfD/+tSHKCXNMdMqGFucmQeuD1W+qgt3NuM8MvDnaH8zu9efpUi7PLhb5oiQDmAZV0QxjOztFFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net 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=GiOv6fetb5tJfAtb3nn2oCe7rTw+/dBwnzw7/uYCGn0=; b=ExR5qsuUhPzRIXxThlNMUNS0yLa7OuLKMvjRyjp0p0c39eN0rBuV6r7qlYnHkyWGOhg68U4cmLHW6Jlw8g/WQkkAHjTne64R0ovKGePXXtgwNHqdOztVRGoO2Xti7v8D7g9ghB7qSbBqC627tgjadRUzDEF2Z3YQB28aWOC6pC4GKwb1I2AD4JfXtBghlYNvFYD3JLrT7eSH320KEUWIm0YioZ+RJJBp+0FpkqyTGQonM2NfGDMQkbORLyNwWBmJfb9zpb6thLsZ+EJGFQcBrceFPpQB0RwasH00mZlbx/kmVviU5ZNxlAvHeRhB48bILgvZ0MeIEn0wncLO+9qVrw== Received: from BN9PR03CA0949.namprd03.prod.outlook.com (2603:10b6:408:108::24) by BL1PR12MB5176.namprd12.prod.outlook.com (2603:10b6:208:311::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Wed, 10 Nov 2021 06:52:15 +0000 Received: from BN8NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:408:108:cafe::ab) by BN9PR03CA0949.outlook.office365.com (2603:10b6:408:108::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13 via Frontend Transport; Wed, 10 Nov 2021 06:52:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) 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.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 BN8NAM11FT023.mail.protection.outlook.com (10.13.177.103) 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:52:14 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 10 Nov 2021 06:52:08 +0000 From: Xueming Li To: Dmitry Kozlyuk CC: Luca Boccassi , Harman Kalra , Thomas Monjalon , dpdk stable Date: Wed, 10 Nov 2021 14:31:00 +0800 Message-ID: <20211110063216.2744012-177-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.5] 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: ab5b302b-2f5f-47c6-0e3c-08d9a416a165 X-MS-TrafficTypeDiagnostic: BL1PR12MB5176: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Vga+joLOOqcQqCdX10TffU29rbgwQfdLDCRvumvPBsdybLJ+aZTSqhDkVfRJAS0BoVdrHyS5eYSiT9dGouuVcXiEvvqP2owpHLDmlLRu9qh5pYIL3xU0Xd9R1QVcORB2eRO9k/qsCcFrItpsSEkBBSbCOz1FIrr77HLDDHcrVv75kJPOks2j750K5bvWKIy8SYApNIRCtds4RHhvwz0FZpTprihl434RSAltN2Nk8ig0CjgFpRX9oYmJ1S4lb7mw3MpO922PKvwOmwIOED7+KOmus++dcPsD9ypmpoC2GyvtUFxMr/E7VwAInk8Y7T6I9cRSwKkTv686CZr//diVXjhj0Rop0qwX5+Vo3mPX91vKhD5w1TNMhfNtwxA83BBfGaNQ4eI+TWN9GSc5f5I6OLrWnsJ7E4x9+b/knGCS3z7SZyQbAVHLy83AvssgIF1WxGd5zyLExcj7Ef51+khfSe5WrOpxHgI2wW7Ulr6/wqAY+WGO8iBEivd0Qi6eGNbXBGeOBB85lp0PasZeu0IEBw4ttECHNuCsJOzl1vS43mQt7o2PhIEpQ50I+51Y3j/VyOets1j1VJs3vUbFrC0dLlyIfSr0Hc4Q3ABflri1yM3sTXpYjokrQ1VAwHgUP2iYgV1/tTs4qBamX0KK4DT/IybxdCgvDN7QV3r8suc8P7dbTWGI3PRUo/KtCJEKnbpGaJxTOA8dW/pcQfucWP+UX6j+5eewGAvGTL8Hc5iuiGSY5m65wFiIAKmKzzMwamAKEXbBrmCL4eiTzah/mqnBU2n8JfblP85Qizc78PT05Q0h0jULONh4W3WP7AZV64swQqvnyNo0Xy0RMVgMmoZMVg== 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)(36860700001)(2906002)(86362001)(36756003)(4326008)(356005)(6636002)(6666004)(6862004)(47076005)(5660300002)(55016002)(37006003)(36906005)(7636003)(966005)(40140700001)(426003)(4001150100001)(54906003)(6286002)(8676002)(316002)(16526019)(83380400001)(508600001)(1076003)(336012)(186003)(8936002)(26005)(53546011)(82310400003)(70206006)(70586007)(7696005)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 06:52:14.7909 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ab5b302b-2f5f-47c6-0e3c-08d9a416a165 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: BN8NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5176 Subject: [dpdk-stable] patch 'net/mlx5: close tools socket with last device' 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/315ca5d5358aa3089510df129d0c7f144714c4ba Thanks. Xueming Li --- >From 315ca5d5358aa3089510df129d0c7f144714c4ba Mon Sep 17 00:00:00 2001 From: Dmitry Kozlyuk Date: Thu, 14 Oct 2021 11:55:28 +0300 Subject: [PATCH] net/mlx5: close tools socket with last device Cc: Xueming Li [ upstream commit ea823b2c511d6e4a4e51fa5e4aabc30e5a30cdb7 ] MLX5 PMD exposes a socket for external tools to dump port state. Socket events are listened using an interrupt source of EXT type. The socket was closed and the interrupt callback was unregistered at program exit, which is incorrect because DPDK could be already shut down at this point. Move actions performed at program exit to the moment the last MLX5 port is closed. The socket will be opened again if later a new MLX5 device is plugged in and probed. Also fix comments that were decisively talking about secondary processes instead of external tools. Fixes: e6cdc54cc0ef ("net/mlx5: add socket server for external tools") Reported-by: Harman Kalra Signed-off-by: Dmitry Kozlyuk Acked-by: Thomas Monjalon --- drivers/net/mlx5/linux/mlx5_os.c | 9 +++++++++ drivers/net/mlx5/linux/mlx5_socket.c | 12 +++--------- drivers/net/mlx5/mlx5.c | 4 ++++ drivers/net/mlx5/mlx5.h | 2 ++ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index cc4fa3dd97..e4bb26bc2b 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -2463,6 +2463,15 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn, return err; } +/** + * Cleanup resources when the last device is closed. + */ +void +mlx5_os_net_cleanup(void) +{ + mlx5_pmd_socket_uninit(); +} + /** * Install shared asynchronous device events handler. * This function is implemented to support event sharing diff --git a/drivers/net/mlx5/linux/mlx5_socket.c b/drivers/net/mlx5/linux/mlx5_socket.c index b1f41bc102..e60d1ec212 100644 --- a/drivers/net/mlx5/linux/mlx5_socket.c +++ b/drivers/net/mlx5/linux/mlx5_socket.c @@ -140,10 +140,7 @@ mlx5_pmd_interrupt_handler_uninstall(void) } /** - * Initialise the socket to communicate with the secondary process - * - * @param[in] dev - * Pointer to Ethernet device. + * Initialise the socket to communicate with external tools. * * @return * 0 on success, a negative value otherwise. @@ -160,10 +157,6 @@ mlx5_pmd_socket_init(void) MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY); if (server_socket) return 0; - /* - * Initialize the socket to communicate with the secondary - * process. - */ ret = socket(AF_UNIX, SOCK_STREAM, 0); if (ret < 0) { DRV_LOG(WARNING, "Failed to open mlx5 socket: %s", @@ -210,7 +203,8 @@ error: /** * Un-Initialize the pmd socket */ -RTE_FINI(mlx5_pmd_socket_uninit) +void +mlx5_pmd_socket_uninit(void) { if (!server_socket) return; diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 48588d4cd5..ef1308ffc1 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1079,6 +1079,10 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh) mlx5_mr_release_cache(&sh->share_cache); /* Remove context from the global device list. */ LIST_REMOVE(sh, next); + /* Release resources on the last device removal. */ + if (LIST_EMPTY(&mlx5_dev_ctx_list)) { + mlx5_os_net_cleanup(); + } pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex); /* * Ensure there is no async event handler installed. diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 3d6d5bb923..7e984f8438 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1261,6 +1261,7 @@ int mlx5_mp_os_req_queue_control(struct rte_eth_dev *dev, uint16_t queue_id, /* mlx5_socket.c */ int mlx5_pmd_socket_init(void); +void mlx5_pmd_socket_uninit(void); /* mlx5_flow_meter.c */ @@ -1298,6 +1299,7 @@ int mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable); int mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable); int mlx5_os_set_nonblock_channel_fd(int fd); void mlx5_os_mac_addr_flush(struct rte_eth_dev *dev); +void mlx5_os_net_cleanup(void); /* mlx5_txpp.c */ -- 2.33.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-11-10 14:17:09.746918599 +0800 +++ 0176-net-mlx5-close-tools-socket-with-last-device.patch 2021-11-10 14:17:01.987411803 +0800 @@ -1 +1 @@ -From ea823b2c511d6e4a4e51fa5e4aabc30e5a30cdb7 Mon Sep 17 00:00:00 2001 +From 315ca5d5358aa3089510df129d0c7f144714c4ba Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit ea823b2c511d6e4a4e51fa5e4aabc30e5a30cdb7 ] @@ -17 +19,0 @@ -Cc: stable@dpdk.org @@ -25 +27 @@ - drivers/net/mlx5/mlx5.c | 6 ++++-- + drivers/net/mlx5/mlx5.c | 4 ++++ @@ -27,2 +29 @@ - drivers/net/mlx5/windows/mlx5_os.c | 8 ++++++++ - 5 files changed, 26 insertions(+), 11 deletions(-) + 4 files changed, 18 insertions(+), 9 deletions(-) @@ -31 +32 @@ -index 7de60ac3d7..0eff7930b4 100644 +index cc4fa3dd97..e4bb26bc2b 100644 @@ -34,2 +35,2 @@ -@@ -2666,6 +2666,15 @@ mlx5_os_net_probe(struct mlx5_common_device *cdev) - return mlx5_os_auxiliary_probe(cdev); +@@ -2463,6 +2463,15 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn, + return err; @@ -51 +52 @@ -index 6356b66dc4..902b8ec934 100644 +index b1f41bc102..e60d1ec212 100644 @@ -54 +55 @@ -@@ -167,10 +167,7 @@ mlx5_pmd_interrupt_handler_uninstall(void) +@@ -140,10 +140,7 @@ mlx5_pmd_interrupt_handler_uninstall(void) @@ -66 +67 @@ -@@ -187,10 +184,6 @@ mlx5_pmd_socket_init(void) +@@ -160,10 +157,6 @@ mlx5_pmd_socket_init(void) @@ -77 +78 @@ -@@ -237,7 +230,8 @@ error: +@@ -210,7 +203,8 @@ error: @@ -88 +89 @@ -index 4a1b85b927..f827318fd0 100644 +index 48588d4cd5..ef1308ffc1 100644 @@ -91,2 +92,2 @@ -@@ -1363,9 +1363,11 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh) - } +@@ -1079,6 +1079,10 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh) + mlx5_mr_release_cache(&sh->share_cache); @@ -95,2 +95,0 @@ -- /* Release flow workspaces objects on the last device. */ -- if (LIST_EMPTY(&mlx5_dev_ctx_list)) @@ -100 +98,0 @@ - mlx5_flow_os_release_workspace(); @@ -106 +104 @@ -index adef86d3ae..d8694d7a6b 100644 +index 3d6d5bb923..7e984f8438 100644 @@ -109 +107 @@ -@@ -1706,6 +1706,7 @@ int mlx5_mp_os_req_queue_control(struct rte_eth_dev *dev, uint16_t queue_id, +@@ -1261,6 +1261,7 @@ int mlx5_mp_os_req_queue_control(struct rte_eth_dev *dev, uint16_t queue_id, @@ -117 +115 @@ -@@ -1749,6 +1750,7 @@ int mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable); +@@ -1298,6 +1299,7 @@ int mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable); @@ -125,17 +122,0 @@ -diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c -index 685babe0ae..fdf3b957c7 100644 ---- a/drivers/net/mlx5/windows/mlx5_os.c -+++ b/drivers/net/mlx5/windows/mlx5_os.c -@@ -949,4 +949,12 @@ mlx5_os_net_probe(struct mlx5_common_device *cdev) - return 0; - } - -+/** -+ * Cleanup resources when the last device is closed. -+ */ -+void -+mlx5_os_net_cleanup(void) -+{ -+} -+ - const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = {0};