From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 762D1A04A4; Wed, 3 Jun 2020 17:06:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EB9951D580; Wed, 3 Jun 2020 17:06:13 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2067.outbound.protection.outlook.com [40.107.20.67]) by dpdk.org (Postfix) with ESMTP id A33F41D533 for ; Wed, 3 Jun 2020 17:06:10 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O24YpAtkuZzHwaZQlnBM0Yj/aqa0mC3Egt7Z4+cFXn4ewlVkV6HJ2YjBxM4e167uBCY+rWxIMAnhfce+PN/i3iviaaEjaTi2YLg6xi8pLkP8/4bbgbtXuu/9i0xtj6+N4KcKvbUZUD8PDS5Qu6L4n/N9+nEt3jiZLOcEfAKx9uMsBPyOClU0UAehKYoo10OJZmJhsQTH7PGxRW7VAONw6HPDPSxplM/QxMaoNXJhFGwW1trBAn4dSHczWhLrIWTt2dnB3OoatOP0RoIN0nYELrrPOHkxBw3XDuB4RXbVdQaAF1HUAezbCxVbvOcskwADOm6oyC2TJu16n4QtVcBEgQ== 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-SenderADCheck; bh=dRC4WPjLrqtAC1qfCtoQef8sVPjJoRFdoVGPxnR16Hs=; b=c8zhsau7vszVlPJ4yljAFvLgasM20gPYW3bZbbv8wwMu0XAIvsdLNdQqgFwjJOD7x3Ab3/890E/z2Ss5m0iB2Ip2ED9JMt7FR9ncHnf746t0NSMccF5v/22WA5PiLP/e/Tp6AB9aKrAcxajzcAjcx5NKADXPzhzTqRbchE6qJ0YeOp32ETXN5a+P+ZYYlWonhFQxmu1wZM+IeWv9Orl45VskGUrL4ca83tdjcy4hAkxeEvggy2NGGMFaytsw+jhjJq1GB9V/vAOtYdKVwEWzGS+StpKG5PeIX4yKF9maMCiaNmGbw9yffQdQZBMtvek3niIRLzC4wt+/2UKhq8lvZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dRC4WPjLrqtAC1qfCtoQef8sVPjJoRFdoVGPxnR16Hs=; b=nMAg3KICWQ7bWJ3iEwkJaV7hoTGVa6rMN1VKMujPkQhvQQz2A36RMoYL/eLQt9wZRbIbL9IMTDLfE8Z8l/lWMd+MMd97X9uYIvRt/5cWgElro4Tvp+kEobSPeuzFkz+yVBCjXJCIYQKne24v5vsT0NpT5DO13OGiN5tQDaFOyqQ= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB4209.eurprd05.prod.outlook.com (2603:10a6:208:61::22) by AM0PR05MB5235.eurprd05.prod.outlook.com (2603:10a6:208:f5::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Wed, 3 Jun 2020 15:06:09 +0000 Received: from AM0PR05MB4209.eurprd05.prod.outlook.com ([fe80::1068:89a9:41d3:b14a]) by AM0PR05MB4209.eurprd05.prod.outlook.com ([fe80::1068:89a9:41d3:b14a%3]) with mapi id 15.20.3066.018; Wed, 3 Jun 2020 15:06:09 +0000 From: Ophir Munk To: dev@dpdk.org, Matan Azrad , Raslan Darawsheh Cc: Ophir Munk Date: Wed, 3 Jun 2020 15:05:56 +0000 Message-Id: <20200603150602.4686-3-ophirmu@mellanox.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20200603150602.4686-1-ophirmu@mellanox.com> References: <20200603150602.4686-1-ophirmu@mellanox.com> Content-Type: text/plain X-ClientProxiedBy: AM4PR0302CA0033.eurprd03.prod.outlook.com (2603:10a6:205:2::46) To AM0PR05MB4209.eurprd05.prod.outlook.com (2603:10a6:208:61::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (37.142.13.130) by AM4PR0302CA0033.eurprd03.prod.outlook.com (2603:10a6:205:2::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.19 via Frontend Transport; Wed, 3 Jun 2020 15:06:09 +0000 X-Mailer: git-send-email 2.8.4 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2e640fae-e8cb-47e2-bae6-08d807cfa5e3 X-MS-TrafficTypeDiagnostic: AM0PR05MB5235: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 04238CD941 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QHD7zvGwzg1O5yaXrhmt+DyBW8708HqyAsFVS8qXTAJCB60/0jxXvzoS16m0p9JBUFTNQWv/vYKf62UQtw8ucwC9RrHMHH5KmB/cpN88WXWDhiokJ6k1FlRoWaiZmfJihnYfpJPUsAYUF7a2vmhB+FZseLPGX07zH7p7wxXQATR96dpf7cfQiQtTwBuxJrQQFeyCu2Tt2T/R/fXnM7btps/ys5x2rNhwL1sEwg4R41JcDrAQixJtgoVXfpqHUITqhmRTepZj9/XQLL4idg9r3Yj7UHxvPenLzMLEbGja30il7farxVmjHlz3XvcXAyX9 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB4209.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(366004)(136003)(346002)(39860400002)(376002)(26005)(4326008)(186003)(478600001)(316002)(8676002)(16526019)(8886007)(6666004)(2906002)(66476007)(8936002)(66946007)(956004)(66556008)(2616005)(55016002)(107886003)(86362001)(83380400001)(36756003)(6636002)(7696005)(5660300002)(1076003)(52116002)(110136005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 9tGrRuH3VqkGVDswXqvoVva7lDwedKcr2QiT6XG2I/RlFsqLAQ+vrsGuYWoJYfsPVl2HlbhSpcie5hdbV1GxEALIvlgALKdJvIUreInhwBa5muc2qgSSPr4WJNjbzcrOiDCmKscQs3fmooitFMJAuYXWzRplWcxNCNFfuMAxCe14bst0B8rhA1H6batGQgoB2CAJMsaCwDkdpKXbFC8DUrZpFujz/kZiRRn/u0lEuzc3Iwe2l1O+oYluTeg0LTlNoR1ZTi+pVpvV7sQdUi6UL9Zo7PfJeA1hEd4Z6rwY1/TM77PgFYvvP0+kUpjewoecrlicPeqjx5kYBw1sYJ56KQ5Sd60uYP61gZZO8UwcwuoG8+upKAFKYHxS4WnM65Ikh7TvD0siXGyKEPmBgfr3toMBs3CUyEdZBOf3tUFXGuzCeXfUeQMB080Fi3KSrF10iOqGci5gJcUUt3G4uGld+zjVrCQbKkbpoUWipc6/VeOhBMupGL32Gwfk/uJX7hKN X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e640fae-e8cb-47e2-bae6-08d807cfa5e3 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2020 15:06:09.8483 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pImEtNBjbZLbdJIDGn4iHxfoHSg+/9uGEEyWX4W3A/B7Oz0wxwA3USKA80Z5itrLbV1Bg0Ai9uDfJpBNdv3zKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB5235 Subject: [dpdk-dev] [PATCH v1 2/8] net/mlx5: add mlx5 Linux specific file with getter functions 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" 'ctx' type (field in 'struct mlx5_ctx_shared') is changed from 'struct ibv_context *' to 'void *'. 'ctx' members which are verbs dependent (e.g. device_name) will be accessed through getter functions which are added to a new file under Linux directory: linux/mlx5_os.c. Signed-off-by: Ophir Munk Acked-by: Matan Azrad --- drivers/net/mlx5/Makefile | 1 + drivers/net/mlx5/linux/meson.build | 8 ++++ drivers/net/mlx5/linux/mlx5_os.c | 87 ++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/meson.build | 5 ++- drivers/net/mlx5/mlx5.c | 18 ++++---- drivers/net/mlx5/mlx5.h | 6 ++- drivers/net/mlx5/mlx5_mp.c | 2 +- 7 files changed, 115 insertions(+), 12 deletions(-) create mode 100644 drivers/net/mlx5/linux/meson.build create mode 100644 drivers/net/mlx5/linux/mlx5_os.c diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index c160e6b..115b66c 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -32,6 +32,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow_verbs.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mp.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_utils.c SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_socket.c +SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_os.c # Basic CFLAGS. CFLAGS += -O3 diff --git a/drivers/net/mlx5/linux/meson.build b/drivers/net/mlx5/linux/meson.build new file mode 100644 index 0000000..2ea0792 --- /dev/null +++ b/drivers/net/mlx5/linux/meson.build @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2020 Mellanox Technologies, Ltd + +includes += include_directories('.') +sources += files( + 'mlx5_os.c', +) + diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c new file mode 100644 index 0000000..9443239 --- /dev/null +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -0,0 +1,87 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2015 6WIND S.A. + * Copyright 2020 Mellanox Technologies, Ltd + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Verbs header. */ +/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */ +#ifdef PEDANTIC +#pragma GCC diagnostic ignored "-Wpedantic" +#endif +#include +#ifdef PEDANTIC +#pragma GCC diagnostic error "-Wpedantic" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "mlx5_defs.h" +#include "mlx5.h" +#include "mlx5_utils.h" +#include "mlx5_rxtx.h" +#include "mlx5_autoconf.h" +#include "mlx5_mr.h" +#include "mlx5_flow.h" +#include "rte_pmd_mlx5.h" + +/** + * Get ibv device name. Given an ibv_context pointer - return a + * pointer to the corresponding device name. + * + * @param[in] ctx + * Pointer to ibv context. + * + * @return + * Pointer to device name if ctx is valid, NULL otherwise. + */ +const char * +mlx5_os_get_ctx_device_name(void *ctx) +{ + if (!ctx) + return NULL; + return ((struct ibv_context *)ctx)->device->name; +} + +/** + * Get ibv device path name. Given an ibv_context pointer - return a + * pointer to the corresponding device path name. + * + * @param[in] ctx + * Pointer to ibv context. + * + * @return + * Pointer to device path name if ctx is valid, NULL otherwise. + */ +const char * +mlx5_os_get_ctx_device_path(void *ctx) +{ + if (!ctx) + return NULL; + + return ((struct ibv_context *)ctx)->device->ibdev_path; +} diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build index 928663a..e71b2c5 100644 --- a/drivers/net/mlx5/meson.build +++ b/drivers/net/mlx5/meson.build @@ -2,9 +2,9 @@ # Copyright 2018 6WIND S.A. # Copyright 2018 Mellanox Technologies, Ltd -if not is_linux +if not (is_linux or is_windows) build = false - reason = 'only supported on Linux' + reason = 'only supported on Linux and Windows' subdir_done() endif @@ -52,3 +52,4 @@ if get_option('buildtype').contains('debug') else cflags += [ '-UPEDANTIC' ] endif +subdir(exec_env) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index f942f92..95a34d1 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -677,13 +677,14 @@ mlx5_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh) int flags; sh->intr_handle.fd = -1; - flags = fcntl(sh->ctx->async_fd, F_GETFL); - ret = fcntl(sh->ctx->async_fd, F_SETFL, flags | O_NONBLOCK); + flags = fcntl(((struct ibv_context *)sh->ctx)->async_fd, F_GETFL); + ret = fcntl(((struct ibv_context *)sh->ctx)->async_fd, + F_SETFL, flags | O_NONBLOCK); if (ret) { DRV_LOG(INFO, "failed to change file descriptor async event" " queue"); } else { - sh->intr_handle.fd = sh->ctx->async_fd; + sh->intr_handle.fd = ((struct ibv_context *)sh->ctx)->async_fd; sh->intr_handle.type = RTE_INTR_HANDLE_EXT; if (rte_intr_callback_register(&sh->intr_handle, mlx5_dev_interrupt_handler, sh)) { @@ -831,10 +832,10 @@ mlx5_alloc_shared_ibctx(const struct mlx5_dev_spawn_data *spawn, } sh->refcnt = 1; sh->max_port = spawn->max_port; - strncpy(sh->ibdev_name, sh->ctx->device->name, - sizeof(sh->ibdev_name)); - strncpy(sh->ibdev_path, sh->ctx->device->ibdev_path, - sizeof(sh->ibdev_path)); + strncpy(sh->ibdev_name, mlx5_os_get_ctx_device_name(sh->ctx), + sizeof(sh->ibdev_name) - 1); + strncpy(sh->ibdev_path, mlx5_os_get_ctx_device_path(sh->ctx), + sizeof(sh->ibdev_path) - 1); /* * Setting port_id to max unallowed value means * there is no interrupt subhandler installed for @@ -1515,7 +1516,8 @@ mlx5_dev_close(struct rte_eth_dev *dev) return; DRV_LOG(DEBUG, "port %u closing device \"%s\"", dev->data->port_id, - ((priv->sh->ctx != NULL) ? priv->sh->ctx->device->name : "")); + ((priv->sh->ctx != NULL) ? + mlx5_os_get_ctx_device_name(priv->sh->ctx) : "")); /* * If default mreg copy action is removed at the stop stage, * the search will return none and nothing will be done anymore. diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 4f2ca15..d020c10 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -493,7 +493,7 @@ struct mlx5_dev_ctx_shared { uint32_t refcnt; uint32_t devx:1; /* Opened with DV. */ uint32_t max_port; /* Maximal IB device port index. */ - struct ibv_context *ctx; /* Verbs/DV context. */ + void *ctx; /* Verbs/DV/DevX context. */ struct ibv_pd *pd; /* Protection Domain. */ uint32_t pdn; /* Protection Domain number. */ uint32_t tdn; /* Transport Domain number. */ @@ -853,4 +853,8 @@ struct mlx5_flow_meter *mlx5_flow_meter_attach struct rte_flow_error *error); void mlx5_flow_meter_detach(struct mlx5_flow_meter *fm); +/* mlx5_os.c */ +const char *mlx5_os_get_ctx_device_name(void *ctx); +const char *mlx5_os_get_ctx_device_path(void *ctx); + #endif /* RTE_PMD_MLX5_H_ */ diff --git a/drivers/net/mlx5/mlx5_mp.c b/drivers/net/mlx5/mlx5_mp.c index 7ad322d..a2b5c40 100644 --- a/drivers/net/mlx5/mlx5_mp.c +++ b/drivers/net/mlx5/mlx5_mp.c @@ -52,7 +52,7 @@ mlx5_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer) case MLX5_MP_REQ_VERBS_CMD_FD: mp_init_msg(&priv->mp_id, &mp_res, param->type); mp_res.num_fds = 1; - mp_res.fds[0] = priv->sh->ctx->cmd_fd; + mp_res.fds[0] = ((struct ibv_context *)priv->sh->ctx)->cmd_fd; res->result = 0; ret = rte_mp_reply(&mp_res, peer); break; -- 2.8.4