From patchwork Mon Feb 10 10:32:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 65687 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D387CA052F; Mon, 10 Feb 2020 11:32:31 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CFAF51BE9C; Mon, 10 Feb 2020 11:32:28 +0100 (CET) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 4408E1BE94 for ; Mon, 10 Feb 2020 11:32:27 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E8BEB21873; Mon, 10 Feb 2020 05:32:26 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 10 Feb 2020 05:32:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=QgrBtlZlNq +6D2nyqghqqu8tbjm+kynIsfeOT81ljtc=; b=YTw3gBfE/QI+XQgf4CILS/m2Bf nekG8Jo8mFxXfwgLBIOBezZvz4uMGbXAvdE+R5FC1urY8xh3dIVJMwgxz4C6Hs1l fKFcZJHK2y/y3MECqgDtfxlGcZdDcUYuWIn+KZKPBW4G3qjip5j5Y7nWviTKQiIO qGTWQr1uY0MgC9f0s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=QgrBtlZlNq+6D2nyqghqqu8tbjm+kynIsfeOT81ljtc=; b=MWjM0X0p ditekGHoGITAKeGNhGwjDgL4/9a3Lws4jx2Arg64JOtH+gwQCE+q6l5ddA4+yIlk l57ukYIEfD0xU+fyRXmAH2JhGzEpxjjAciQ7imWJaNrwHoHr/DRE1XSfu419nka6 H+5lr5DpTi79WaD+tiai3h96K5ZAm6wVpctmeMEP1XGBwOlk2asM/BVqOShnmour fNbpMmCw6kqbu/nIGuYGhGL4rB84pzxu3oJsWC32unr+gClnxfQY4LGWQIeTEdTp 1+jt6yiOTs+q/Eb+ycTKXpAW4MmCQiuNAD1CXknDaVpneRTJB5aQGN2X4Q+NLrPp DC2KRcA8bpzo1g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedriedugdduiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucfkph epjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 160BD3280066; Mon, 10 Feb 2020 05:32:26 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko Date: Mon, 10 Feb 2020 11:32:14 +0100 Message-Id: <20200210103216.1168439-2-thomas@monjalon.net> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210103216.1168439-1-thomas@monjalon.net> References: <20200210103216.1168439-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/3] common/mlx5: split glue initialization X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The function mlx5_glue_init was doing three things: - initialize logs - load glue library if in dlopen mode - initialize glue layer They are split in three functions for clarity. The config option RTE_IBVERBS_LINK_DLOPEN is not used anymore outside of make and meson files. It is replaced with MLX5_GLUE, which is defined in the same condition and is already used with dlopen. Signed-off-by: Thomas Monjalon --- drivers/common/mlx5/mlx5_common.c | 77 +++++++++++++++++++------------ 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 610fb480b5..f96506c27a 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -160,7 +160,7 @@ mlx5_translate_port_name(const char *port_name_in, return; } -#ifdef RTE_IBVERBS_LINK_DLOPEN +#ifdef MLX5_GLUE /** * Suffix RTE_EAL_PMD_PATH with "-glue". @@ -202,36 +202,12 @@ mlx5_glue_path(char *buf, size_t size) " re-configure DPDK"); return NULL; } -#endif -/** - * Initialization routine for run-time dependency on rdma-core. - */ -RTE_INIT_PRIO(mlx5_glue_init, CLASS) +static int +mlx5_glue_dlopen(void) { void *handle = NULL; - /* Initialize common log type. */ - mlx5_common_logtype = rte_log_register("pmd.common.mlx5"); - if (mlx5_common_logtype >= 0) - rte_log_set_level(mlx5_common_logtype, RTE_LOG_NOTICE); - /* - * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use - * huge pages. Calling ibv_fork_init() during init allows - * applications to use fork() safely for purposes other than - * using this PMD, which is not supported in forked processes. - */ - setenv("RDMAV_HUGEPAGES_SAFE", "1", 1); - /* Match the size of Rx completion entry to the size of a cacheline. */ - if (RTE_CACHE_LINE_SIZE == 128) - setenv("MLX5_CQE_SIZE", "128", 0); - /* - * MLX5_DEVICE_FATAL_CLEANUP tells ibv_destroy functions to - * cleanup all the Verbs resources even when the device was removed. - */ - setenv("MLX5_DEVICE_FATAL_CLEANUP", "1", 1); - /* The glue initialization was done earlier by mlx5 common library. */ -#ifdef RTE_IBVERBS_LINK_DLOPEN char glue_path[sizeof(RTE_EAL_PMD_PATH) - 1 + sizeof("-glue")]; const char *path[] = { /* @@ -301,7 +277,49 @@ RTE_INIT_PRIO(mlx5_glue_init, CLASS) goto glue_error; } mlx5_glue = *sym; -#endif /* RTE_IBVERBS_LINK_DLOPEN */ + return 0; + +glue_error: + if (handle) + dlclose(handle); + return -1; +} + +#endif + +RTE_INIT_PRIO(mlx5_log_init, LOG) +{ + mlx5_common_logtype = rte_log_register("pmd.common.mlx5"); + if (mlx5_common_logtype >= 0) + rte_log_set_level(mlx5_common_logtype, RTE_LOG_NOTICE); +} + +/** + * Initialization routine for run-time dependency on rdma-core. + */ +RTE_INIT_PRIO(mlx5_glue_init, CLASS) +{ + /* + * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use + * huge pages. Calling ibv_fork_init() during init allows + * applications to use fork() safely for purposes other than + * using this PMD, which is not supported in forked processes. + */ + setenv("RDMAV_HUGEPAGES_SAFE", "1", 1); + /* Match the size of Rx completion entry to the size of a cacheline. */ + if (RTE_CACHE_LINE_SIZE == 128) + setenv("MLX5_CQE_SIZE", "128", 0); + /* + * MLX5_DEVICE_FATAL_CLEANUP tells ibv_destroy functions to + * cleanup all the Verbs resources even when the device was removed. + */ + setenv("MLX5_DEVICE_FATAL_CLEANUP", "1", 1); + +#ifdef MLX5_GLUE + if (mlx5_glue_dlopen() != 0) + goto glue_error; +#endif + #ifdef RTE_LIBRTE_MLX5_DEBUG /* Glue structure must not contain any NULL pointers. */ { @@ -319,9 +337,8 @@ RTE_INIT_PRIO(mlx5_glue_init, CLASS) } mlx5_glue->fork_init(); return; + glue_error: - if (handle) - dlclose(handle); DRV_LOG(WARNING, "Cannot initialize MLX5 common due to missing" " run-time dependency on rdma-core libraries (libibverbs," " libmlx5)");