DPDK patches and discussions
 help / color / mirror / Atom feed
From: Slava Ovsiienko <viacheslavo@mellanox.com>
To: Vu Pham <vuhuong@mellanox.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: Ori Kam <orika@mellanox.com>, Matan Azrad <matan@mellanox.com>,
	Raslan Darawsheh <rasland@mellanox.com>,
	Vu Pham <vuhuong@mellanox.com>
Subject: Re: [dpdk-dev] [PATCH v3 1/4] common/mlx5: refactor multi-process IPC handling codes to common driver
Date: Wed, 8 Apr 2020 09:05:46 +0000	[thread overview]
Message-ID: <AM4PR05MB3265E71FCB7A0F0271E87F82D2C00@AM4PR05MB3265.eurprd05.prod.outlook.com> (raw)
In-Reply-To: <20200407170058.9274-2-vuhuong@mellanox.com>

> -----Original Message-----
> From: Vu Pham <vuhuong@mellanox.com>
> Sent: Tuesday, April 7, 2020 20:01
> To: dev@dpdk.org
> Cc: Slava Ovsiienko <viacheslavo@mellanox.com>; Ori Kam
> <orika@mellanox.com>; Matan Azrad <matan@mellanox.com>; Raslan
> Darawsheh <rasland@mellanox.com>; Vu Pham <vuhuong@mellanox.com>
> Subject: [PATCH v3 1/4] common/mlx5: refactor multi-process IPC handling
> codes to common driver
> 
> Refactor common multi-process handling codes from net PMD to common
> driver. Using tuple mp_id{name, port_id} as standard input parameter for all
> multi-process IPC APIs instead of using rte_eth_dev.
> 
> Signed-off-by: Vu Pham <vuhuong@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>

> ---
>  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
> 
> 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 <stdio.h>
> +#include <time.h>
> +
> +#include <rte_eal.h>
> +#include <rte_errno.h>
> +
> +#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 = (struct mlx5_mp_param
> *)mp_req.param;
> +	struct mlx5_mp_param *res;
> +	struct timespec ts = {.tv_sec = MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec
> = 0};
> +	int ret;
> +
> +	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
> +	mp_init_msg(mp_id, &mp_req, MLX5_MP_REQ_CREATE_MR);
> +	req->args.addr = addr;
> +	ret = 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 == 1);
> +	mp_res = &mp_rep.msgs[0];
> +	res = (struct mlx5_mp_param *)mp_res->param;
> +	ret = res->result;
> +	if (ret)
> +		rte_errno = -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 = (struct mlx5_mp_param
> *)mp_req.param;
> +	struct mlx5_mp_param *res;
> +	struct timespec ts = {.tv_sec = MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec
> = 0};
> +	int ret;
> +
> +	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
> +	mp_init_msg(mp_id, &mp_req,
> MLX5_MP_REQ_QUEUE_STATE_MODIFY);
> +	req->args.state_modify = *sm;
> +	ret = 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 == 1);
> +	mp_res = &mp_rep.msgs[0];
> +	res = (struct mlx5_mp_param *)mp_res->param;
> +	ret = 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 set.
> + */
> +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 = {.tv_sec = MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec
> = 0};
> +	int ret;
> +
> +	MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
> +	mp_init_msg(mp_id, &mp_req, MLX5_MP_REQ_VERBS_CMD_FD);
> +	ret = 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 == 1);
> +	mp_res = &mp_rep.msgs[0];
> +	res = (struct mlx5_mp_param *)mp_res->param;
> +	if (res->result) {
> +		rte_errno = -res->result;
> +		DRV_LOG(ERR,
> +			"port %u failed to get command FD from primary
> process",
> +			mp_id->port_id);
> +		ret = -rte_errno;
> +		goto exit;
> +	}
> +	MLX5_ASSERT(mp_res->num_fds == 1);
> +	ret = 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() == RTE_PROC_PRIMARY);
> +
> +	/* primary is allowed to not support IPC */
> +	ret = rte_mp_action_register(name, primary_action);
> +	if (ret && rte_errno != ENOTSUP)
> +		return -1;
> +	return 0;
> +}
> +
> +/**
> + * Un-initialize by primary process.
> + */
> +void
> +mlx5_mp_uninit_primary(const char *name) {
> +	MLX5_ASSERT(rte_eal_process_type() == 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() == 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() == 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 <infiniband/verbs.h>
> +#ifdef PEDANTIC
> +#pragma GCC diagnostic error "-Wpedantic"
> +#endif
> +
> +#include <rte_eal.h>
> +#include <rte_string_fns.h>
> +
> +/* Request types for IPC. */
> +enum mlx5_mp_req_type {
> +	MLX5_MP_REQ_VERBS_CMD_FD = 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 = (struct mlx5_mp_param *)msg-
> >param;
> +
> +	memset(msg, 0, sizeof(*msg));
> +	strlcpy(msg->name, mp_id->name, sizeof(msg->name));
> +	msg->len_param = sizeof(*param);
> +	param->type = type;
> +	param->port_id = 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;
> 
>  	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


  reply	other threads:[~2020-04-08  9:05 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-02 19:21 [dpdk-dev] [PATCH 0/4] refactor multi-process IPC and memory management " Vu Pham
2020-04-02 19:21 ` [dpdk-dev] [PATCH 1/4] common/mlx5: refactor multi-process IPC handling " Vu Pham
2020-04-02 19:21 ` [dpdk-dev] [PATCH 2/4] net/mlx5: modify net PMD to use common multi-process APIs Vu Pham
2020-04-02 19:21 ` [dpdk-dev] [PATCH 3/4] common/mlx5: refactor memory management codes Vu Pham
2020-04-02 19:21 ` [dpdk-dev] [PATCH 4/4] net/mlx5: modify net PMD to use common memory management driver Vu Pham
2020-04-07 16:48 ` [dpdk-dev] [PATCH v2 0/4] refactor multi-process IPC and memory management codes to common driver Vu Pham
2020-04-07 16:48   ` [dpdk-dev] [PATCH v2 1/4] common/mlx5: refactor MP IPC handling " Vu Pham
2020-04-08  9:05     ` Slava Ovsiienko
2020-04-07 16:48   ` [dpdk-dev] [PATCH v2 2/4] net/mlx5: modify net pmd to use common multi-process APIs Vu Pham
2020-04-07 16:48   ` [dpdk-dev] [PATCH v2 3/4] common/mlx5: refactor memory management codes Vu Pham
2020-04-07 16:48   ` [dpdk-dev] [PATCH v2 4/4] net/mlx5: modify net pmd to use common MR driver Vu Pham
2020-04-07 17:00 ` [dpdk-dev] [PATCH v3 0/4] refactor multi-process IPC and memory management codes to common driver Vu Pham
2020-04-07 17:00   ` [dpdk-dev] [PATCH v3 1/4] common/mlx5: refactor multi-process IPC handling " Vu Pham
2020-04-08  9:05     ` Slava Ovsiienko [this message]
2020-04-07 17:00   ` [dpdk-dev] [PATCH v3 2/4] net/mlx5: modify net PMD to use common multi-process APIs Vu Pham
2020-04-08  9:05     ` Slava Ovsiienko
2020-04-07 17:00   ` [dpdk-dev] [PATCH v3 3/4] common/mlx5: refactor memory management codes Vu Pham
2020-04-08  9:04     ` Slava Ovsiienko
2020-04-07 17:00   ` [dpdk-dev] [PATCH v3 4/4] net/mlx5: modify net PMD to use common MR driver Vu Pham
2020-04-08  9:06     ` Slava Ovsiienko
2020-04-13 21:17 ` [dpdk-dev] [PATCH v4 0/2] refactor multi-process IPC and memory management codes to common driver Vu Pham
2020-04-13 21:17   ` [dpdk-dev] [PATCH v4 1/2] common/mlx5: refactor multi-process IPC handling " Vu Pham
2020-04-14  7:26     ` Slava Ovsiienko
2020-04-13 21:17   ` [dpdk-dev] [PATCH v4 2/2] common/mlx5: refactor memory management codes Vu Pham
2020-04-14  7:27     ` Slava Ovsiienko
2020-04-15  9:30   ` [dpdk-dev] [PATCH v4 0/2] refactor multi-process IPC and memory management codes to common driver Raslan Darawsheh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM4PR05MB3265E71FCB7A0F0271E87F82D2C00@AM4PR05MB3265.eurprd05.prod.outlook.com \
    --to=viacheslavo@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=matan@mellanox.com \
    --cc=orika@mellanox.com \
    --cc=rasland@mellanox.com \
    --cc=vuhuong@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).