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 68CBAA0597; Wed, 8 Apr 2020 11:05:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 43E261C135; Wed, 8 Apr 2020 11:05:05 +0200 (CEST) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150071.outbound.protection.outlook.com [40.107.15.71]) by dpdk.org (Postfix) with ESMTP id E83961C133 for ; Wed, 8 Apr 2020 11:05:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UZzqHRqrBfkeEh4Pc8/wBbeKUflYtPELfPIlFYuzbMWlhelYjCuLk8wn9ijxUPghrczPWj45uXjTJ4u+h30oH0DVD4Toh8fCKwbhqlVbTO3jnxIDSAMwKszfCX4fnZhXWyPjysENb4033vYrlMeOniPhEaQ6hL+XvCsfQyzEcwo0to/yVsI1lFXt2t35VS3FznRFQfXakshPO61+eoEgGLM0VLBG8kfxSRgx7a61uRDOGlTGMriG4dPkP5p9ongZXEY2TTJfUAROM90PAK+5IGBF6PUHEgO5BkZjOTlnJzbCic52YLJC0v/vjTMooDkrx+/gjszgGZDACWN7PfD0+Q== 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=8lWgq40OfSkpXj7CvfnMSnnAdQKF7eWXLk9Ke5Xes1U=; b=I8SDt08D4iQ64SB8kFIeo/ZEvStvNjKcLLFPrDBmX1cpcPYYUnabs1yrfzAQHUxERPshLn69bwqOph6d34NR6A6aDviY+nm7PXENIeMT26flHaIMkK95ZOtN5EMYosGji6Eu6wRkGV/JbkRGIa976xta40JqbQnhDViTM5nfO3Ky33ip20sWpS8CQfKtAsDdt46nILXVttWvheFj+71tLvMW2bgEivSdgQ9TTGW3DL7aL1HITQwTFt5jIUn6heUo6sHI2tUzR4wPMygr45HpU/xagGH/zBjX/dEilAEibKEwJZ3leOnAMW3WsicP9VR9K6+nWZe1tkIUAjtherO20A== 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=8lWgq40OfSkpXj7CvfnMSnnAdQKF7eWXLk9Ke5Xes1U=; b=p11zMRHspT2SZUAg1O2+QEQ43yacMvTJ+TormZAfDBoeXTw59Jb00vbWQMz9FgNxk8QGvJUw5Wfjw4YM1/vbJu07uEozUrQBeAWLaXtWrDPT8SGi0MQ6I+Q/oSej3Jcpf4ELxTVAZXBLYpNZKUet10Rrqagf6eQ9yJm+xfuoGq0= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (2603:10a6:205:8::26) by AM4PR05MB3267.eurprd05.prod.outlook.com (2603:10a6:205:7::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.20; Wed, 8 Apr 2020 09:05:02 +0000 Received: from AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::da5:7919:35c1:894]) by AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::da5:7919:35c1:894%6]) with mapi id 15.20.2878.018; Wed, 8 Apr 2020 09:05:02 +0000 From: Slava Ovsiienko To: Vu Pham , "dev@dpdk.org" CC: Ori Kam , Matan Azrad , Raslan Darawsheh , Vu Pham Thread-Topic: [PATCH v2 1/4] common/mlx5: refactor MP IPC handling codes to common driver Thread-Index: AQHWDPx6us0g/DETF0+j0NopAtmSEahu743Q Date: Wed, 8 Apr 2020 09:05:01 +0000 Message-ID: References: <20200402192105.11606-1-vuhuoong@mellanox.com> <20200407164812.8780-1-vuhuong@mellanox.com> <20200407164812.8780-2-vuhuong@mellanox.com> In-Reply-To: <20200407164812.8780-2-vuhuong@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=viacheslavo@mellanox.com; x-originating-ip: [95.164.10.10] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: d8b7c9ba-7daa-4900-b052-08d7db9bec61 x-ms-traffictypediagnostic: AM4PR05MB3267:|AM4PR05MB3267: 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:1060; x-forefront-prvs: 0367A50BB1 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM4PR05MB3265.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(396003)(366004)(136003)(346002)(376002)(39860400002)(66946007)(55016002)(66446008)(64756008)(66556008)(5660300002)(66476007)(86362001)(6506007)(107886003)(76116006)(52536014)(54906003)(7696005)(110136005)(2906002)(8936002)(316002)(9686003)(81166007)(81156014)(4326008)(8676002)(478600001)(53546011)(71200400001)(186003)(33656002)(26005); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 83kWtfHpOh4EDAJE8gqnntbJxYSNUrJPudGWYE7jlNVaxZJUF1YtLpzAA1APqlZjstVukRH0rmvSzHpm3MrrppiUwJ6uMXPJFVFbW9YWtA47s3yyo28Ittmg1pWmzsxGe2PM9aBgZL5+gVJVlJ0lLJs+svqGlITfhLAhA4OmUYhpdblXW2an+zJBeLekDUodBdXrzyJR1zqMFR7rVALp6UCpREp/eAcadqwaF6wc5PBKv9Q3DsOZSk5WiSY0q8DWwmR6jZnxVPjODn3CljI8N4afBKkMjYdQUd7OA9Z8mBmYX3jquakIICWKLSGS63p7mHKoxZih4teX/o8ScojsL4bBla8h0GR5wbBiGQIqY+AKHkZKE6WJ0Fkcyh8cSIjR2zgz289ouZWrLB/0ZaVDC5A7fE+jO5nbvBFA8eL66M/aciBoMS4fNwEZ/YCwsyih x-ms-exchange-antispam-messagedata: RYVm8l41DSInFEhgfhiY161442SAnZiWVfpzYsaBuFKEGEu6OwHwqpVnIG5iO2P++Po/pqg+HYS0dSGBrGSZ094OX+s/rKObRn58jKVP1vXembO1KqaqBma0JqtaV/bfITLBytW/jtaMTddfehdbZw== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8b7c9ba-7daa-4900-b052-08d7db9bec61 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2020 09:05:02.7264 (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: 5n6vSMywUNGmZbNutmZlBNtERr0RTmhjFwjiafDhvhGx//CTpd5X5USIop7Z/joiy/+wZnVIL1wMk9FRKmg1+EM3TfirYnDw/3G9icYYjws= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3267 Subject: Re: [dpdk-dev] [PATCH v2 1/4] common/mlx5: refactor MP IPC handling codes to common driver 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" > -----Original Message----- > From: Vu Pham > Sent: Tuesday, April 7, 2020 19:48 > To: dev@dpdk.org > Cc: Slava Ovsiienko ; Ori Kam > ; Matan Azrad ; Raslan > Darawsheh ; Vu Pham > Subject: [PATCH v2 1/4] common/mlx5: refactor MP IPC handling codes to > common driver >=20 > Refactor common mp handling codes from net pmd to common driver. > Using port_id as standard input parameter for all MP IPC APIs instead of = using > rte_eth_dev. >=20 > Signed-off-by: Vu Pham Acked-by: Viacheslav Ovsiienko > --- > drivers/common/mlx5/mlx5_common_mp.c | 188 > ++++++++++++++++++++++++ > drivers/common/mlx5/mlx5_common_mp.h | 98 ++++++++++++ > drivers/common/mlx5/rte_common_mlx5_version.map | 13 ++ > 3 files changed, 299 insertions(+) > create mode 100644 drivers/common/mlx5/mlx5_common_mp.c > create mode 100644 drivers/common/mlx5/mlx5_common_mp.h >=20 > diff --git a/drivers/common/mlx5/mlx5_common_mp.c > b/drivers/common/mlx5/mlx5_common_mp.c > new file mode 100644 > index 0000000000..da55143bc1 > --- /dev/null > +++ b/drivers/common/mlx5/mlx5_common_mp.c > @@ -0,0 +1,188 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright 2019 6WIND S.A. > + * Copyright 2019 Mellanox Technologies, Ltd */ > + > +#include > +#include > + > +#include > +#include > + > +#include "mlx5_common_mp.h" > +#include "mlx5_common_utils.h" > + > +/** > + * Request Memory Region creation to the primary process. > + * > + * @param[in] mp_id > + * ID of the MP process. > + * @param addr > + * Target virtual address to register. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +int > +mlx5_mp_req_mr_create(struct mlx5_mp_id *mp_id, uintptr_t addr) { > + struct rte_mp_msg mp_req; > + struct rte_mp_msg *mp_res; > + struct rte_mp_reply mp_rep; > + struct mlx5_mp_param *req =3D (struct mlx5_mp_param > *)mp_req.param; > + struct mlx5_mp_param *res; > + struct timespec ts =3D {.tv_sec =3D MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec > =3D 0}; > + int ret; > + > + MLX5_ASSERT(rte_eal_process_type() =3D=3D RTE_PROC_SECONDARY); > + mp_init_msg(mp_id, &mp_req, MLX5_MP_REQ_CREATE_MR); > + req->args.addr =3D addr; > + ret =3D rte_mp_request_sync(&mp_req, &mp_rep, &ts); > + if (ret) { > + DRV_LOG(ERR, "port %u request to primary process failed", > + mp_id->port_id); > + return -rte_errno; > + } > + MLX5_ASSERT(mp_rep.nb_received =3D=3D 1); > + mp_res =3D &mp_rep.msgs[0]; > + res =3D (struct mlx5_mp_param *)mp_res->param; > + ret =3D res->result; > + if (ret) > + rte_errno =3D -ret; > + free(mp_rep.msgs); > + return ret; > +} > + > +/** > + * Request Verbs queue state modification to the primary process. > + * > + * @param[in] mp_id > + * ID of the MP process. > + * @param sm > + * State modify parameters. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +int > +mlx5_mp_req_queue_state_modify(struct mlx5_mp_id *mp_id, > + struct mlx5_mp_arg_queue_state_modify *sm) { > + struct rte_mp_msg mp_req; > + struct rte_mp_msg *mp_res; > + struct rte_mp_reply mp_rep; > + struct mlx5_mp_param *req =3D (struct mlx5_mp_param > *)mp_req.param; > + struct mlx5_mp_param *res; > + struct timespec ts =3D {.tv_sec =3D MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec > =3D 0}; > + int ret; > + > + MLX5_ASSERT(rte_eal_process_type() =3D=3D RTE_PROC_SECONDARY); > + mp_init_msg(mp_id, &mp_req, > MLX5_MP_REQ_QUEUE_STATE_MODIFY); > + req->args.state_modify =3D *sm; > + ret =3D rte_mp_request_sync(&mp_req, &mp_rep, &ts); > + if (ret) { > + DRV_LOG(ERR, "port %u request to primary process failed", > + mp_id->port_id); > + return -rte_errno; > + } > + MLX5_ASSERT(mp_rep.nb_received =3D=3D 1); > + mp_res =3D &mp_rep.msgs[0]; > + res =3D (struct mlx5_mp_param *)mp_res->param; > + ret =3D res->result; > + free(mp_rep.msgs); > + return ret; > +} > + > +/** > + * Request Verbs command file descriptor for mmap to the primary process= . > + * > + * @param[in] mp_id > + * ID of the MP process. > + * > + * @return > + * fd on success, a negative errno value otherwise and rte_errno is se= t. > + */ > +int > +mlx5_mp_req_verbs_cmd_fd(struct mlx5_mp_id *mp_id) { > + struct rte_mp_msg mp_req; > + struct rte_mp_msg *mp_res; > + struct rte_mp_reply mp_rep; > + struct mlx5_mp_param *res; > + struct timespec ts =3D {.tv_sec =3D MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec > =3D 0}; > + int ret; > + > + MLX5_ASSERT(rte_eal_process_type() =3D=3D RTE_PROC_SECONDARY); > + mp_init_msg(mp_id, &mp_req, MLX5_MP_REQ_VERBS_CMD_FD); > + ret =3D rte_mp_request_sync(&mp_req, &mp_rep, &ts); > + if (ret) { > + DRV_LOG(ERR, "port %u request to primary process failed", > + mp_id->port_id); > + return -rte_errno; > + } > + MLX5_ASSERT(mp_rep.nb_received =3D=3D 1); > + mp_res =3D &mp_rep.msgs[0]; > + res =3D (struct mlx5_mp_param *)mp_res->param; > + if (res->result) { > + rte_errno =3D -res->result; > + DRV_LOG(ERR, > + "port %u failed to get command FD from primary > process", > + mp_id->port_id); > + ret =3D -rte_errno; > + goto exit; > + } > + MLX5_ASSERT(mp_res->num_fds =3D=3D 1); > + ret =3D mp_res->fds[0]; > + DRV_LOG(DEBUG, "port %u command FD from primary is %d", > + mp_id->port_id, ret); > +exit: > + free(mp_rep.msgs); > + return ret; > +} > + > +/** > + * Initialize by primary process. > + */ > +int > +mlx5_mp_init_primary(const char *name, const rte_mp_t primary_action) { > + int ret; > + > + MLX5_ASSERT(rte_eal_process_type() =3D=3D RTE_PROC_PRIMARY); > + > + /* primary is allowed to not support IPC */ > + ret =3D rte_mp_action_register(name, primary_action); > + if (ret && rte_errno !=3D ENOTSUP) > + return -1; > + return 0; > +} > + > +/** > + * Un-initialize by primary process. > + */ > +void > +mlx5_mp_uninit_primary(const char *name) { > + MLX5_ASSERT(rte_eal_process_type() =3D=3D RTE_PROC_PRIMARY); > + rte_mp_action_unregister(name); > +} > + > +/** > + * Initialize by secondary process. > + */ > +int > +mlx5_mp_init_secondary(const char *name, const rte_mp_t > +secondary_action) { > + MLX5_ASSERT(rte_eal_process_type() =3D=3D RTE_PROC_SECONDARY); > + return rte_mp_action_register(name, secondary_action); } > + > +/** > + * Un-initialize by secondary process. > + */ > +void > +mlx5_mp_uninit_secondary(const char *name) { > + MLX5_ASSERT(rte_eal_process_type() =3D=3D RTE_PROC_SECONDARY); > + rte_mp_action_unregister(name); > +} > diff --git a/drivers/common/mlx5/mlx5_common_mp.h > b/drivers/common/mlx5/mlx5_common_mp.h > new file mode 100644 > index 0000000000..7aab77acb2 > --- /dev/null > +++ b/drivers/common/mlx5/mlx5_common_mp.h > @@ -0,0 +1,98 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright 2018 6WIND S.A. > + * Copyright 2018 Mellanox Technologies, Ltd */ > + > +#ifndef RTE_PMD_MLX5_COMMON_MP_H_ > +#define RTE_PMD_MLX5_COMMON_MP_H_ > + > +/* 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 > + > +/* Request types for IPC. */ > +enum mlx5_mp_req_type { > + MLX5_MP_REQ_VERBS_CMD_FD =3D 1, > + MLX5_MP_REQ_CREATE_MR, > + MLX5_MP_REQ_START_RXTX, > + MLX5_MP_REQ_STOP_RXTX, > + MLX5_MP_REQ_QUEUE_STATE_MODIFY, > +}; > + > +struct mlx5_mp_arg_queue_state_modify { > + uint8_t is_wq; /* Set if WQ. */ > + uint16_t queue_id; /* DPDK queue ID. */ > + enum ibv_wq_state state; /* WQ requested state. */ }; > + > +/* Pameters for IPC. */ > +struct mlx5_mp_param { > + enum mlx5_mp_req_type type; > + int port_id; > + int result; > + RTE_STD_C11 > + union { > + uintptr_t addr; /* MLX5_MP_REQ_CREATE_MR */ > + struct mlx5_mp_arg_queue_state_modify state_modify; > + /* MLX5_MP_REQ_QUEUE_STATE_MODIFY */ > + } args; > +}; > + > +/* Identifier of a MP process */ > +struct mlx5_mp_id { > + char name[RTE_MP_MAX_NAME_LEN]; > + uint16_t port_id; > +}; > + > +/** Request timeout for IPC. */ > +#define MLX5_MP_REQ_TIMEOUT_SEC 5 > + > +/** > + * Initialize IPC message. > + * > + * @param[in] port_id > + * Port ID of the device. > + * @param[out] msg > + * Pointer to message to fill in. > + * @param[in] type > + * Message type. > + */ > +static inline void > +mp_init_msg(struct mlx5_mp_id *mp_id, struct rte_mp_msg *msg, > + enum mlx5_mp_req_type type) > +{ > + struct mlx5_mp_param *param =3D (struct mlx5_mp_param *)msg- > >param; > + > + memset(msg, 0, sizeof(*msg)); > + strlcpy(msg->name, mp_id->name, sizeof(msg->name)); > + msg->len_param =3D sizeof(*param); > + param->type =3D type; > + param->port_id =3D mp_id->port_id; > +} > + > +__rte_experimental > +int mlx5_mp_init_primary(const char *name, const rte_mp_t > +primary_action); __rte_experimental void mlx5_mp_uninit_primary(const > +char *name); __rte_experimental int mlx5_mp_init_secondary(const char > +*name, const rte_mp_t secondary_action); __rte_experimental void > +mlx5_mp_uninit_secondary(const char *name); __rte_experimental int > +mlx5_mp_req_mr_create(struct mlx5_mp_id *mp_id, uintptr_t addr); > +__rte_experimental int mlx5_mp_req_queue_state_modify(struct > mlx5_mp_id > +*mp_id, > + struct mlx5_mp_arg_queue_state_modify > *sm); __rte_experimental > +int mlx5_mp_req_verbs_cmd_fd(struct mlx5_mp_id *mp_id); > + > +#endif /* RTE_PMD_MLX5_COMMON_MP_H_ */ > diff --git a/drivers/common/mlx5/rte_common_mlx5_version.map > b/drivers/common/mlx5/rte_common_mlx5_version.map > index aede2a0a51..265703d1c9 100644 > --- a/drivers/common/mlx5/rte_common_mlx5_version.map > +++ b/drivers/common/mlx5/rte_common_mlx5_version.map > @@ -48,4 +48,17 @@ DPDK_20.0.1 { > mlx5_nl_vlan_vmwa_delete; >=20 > mlx5_translate_port_name; > + > +}; > + > +EXPERIMENTAL { > + global: > + > + mlx5_mp_init_primary; > + mlx5_mp_uninit_primary; > + mlx5_mp_init_secondary; > + mlx5_mp_uninit_secondary; > + mlx5_mp_req_mr_create; > + mlx5_mp_req_queue_state_modify; > + mlx5_mp_req_verbs_cmd_fd; > }; > -- > 2.16.6