SRCS-y += mlx5_devx_cmds.c
SRCS-y += mlx5_common.c
SRCS-y += mlx5_nl.c
+SRCS-y += mlx5_common_mp.c
ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)
INSTALL-y-lib += $(LIB_GLUE)
endif
'mlx5_devx_cmds.c',
'mlx5_common.c',
'mlx5_nl.c',
+ 'mlx5_common_mp.c',
)
if not dlopen_ibverbs
sources += files('mlx5_glue.c')
--- /dev/null
+/* 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);
+}
--- /dev/null
+/* 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_ */
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;
};
#include <mlx5_glue.h>
#include <mlx5_devx_cmds.h>
#include <mlx5_common.h>
+#include <mlx5_common_mp.h>
#include "mlx5_defs.h"
#include "mlx5.h"
rte_rwlock_init(&sd->mem_event_rwlock);
rte_mem_event_callback_register("MLX5_MEM_EVENT_CB",
mlx5_mr_mem_event_cb, NULL);
- ret = mlx5_mp_init_primary();
+ ret = mlx5_mp_init_primary(MLX5_MP_NAME,
+ mlx5_mp_primary_handle);
if (ret)
goto out;
sd->init_done = true;
case RTE_PROC_SECONDARY:
if (ld->init_done)
break;
- ret = mlx5_mp_init_secondary();
+ ret = mlx5_mp_init_secondary(MLX5_MP_NAME,
+ mlx5_mp_secondary_handle);
if (ret)
goto out;
++sd->secondary_cnt;
}
DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name);
if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+ struct mlx5_mp_id mp_id;
+
eth_dev = rte_eth_dev_attach_secondary(name);
if (eth_dev == NULL) {
DRV_LOG(ERR, "can not attach rte ethdev");
err = mlx5_proc_priv_init(eth_dev);
if (err)
return NULL;
+ mp_id.port_id = eth_dev->data->port_id;
+ strlcpy(mp_id.name, MLX5_MP_NAME, RTE_MP_MAX_NAME_LEN);
/* Receive command fd from primary process */
- err = mlx5_mp_req_verbs_cmd_fd(eth_dev);
+ err = mlx5_mp_req_verbs_cmd_fd(&mp_id);
if (err < 0)
return NULL;
/* Remap UAR for Tx queues. */
priv->ibv_port = spawn->ibv_port;
priv->pci_dev = spawn->pci_dev;
priv->mtu = RTE_ETHER_MTU;
+ priv->mp_id.port_id = port_id;
+ strlcpy(priv->mp_id.name, MLX5_MP_NAME, RTE_MP_MAX_NAME_LEN);
#ifndef RTE_ARCH_64
/* Initialize UAR access locks for 32bit implementations. */
rte_spinlock_init(&priv->uar_lock_cq);
#include <mlx5_devx_cmds.h>
#include <mlx5_prm.h>
#include <mlx5_nl.h>
+#include <mlx5_common_mp.h>
#include "mlx5_defs.h"
#include "mlx5_utils.h"
#include "mlx5_mr.h"
#include "mlx5_autoconf.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;
-};
-
-/** Request timeout for IPC. */
-#define MLX5_MP_REQ_TIMEOUT_SEC 5
-
/** Key string for IPC. */
#define MLX5_MP_NAME "net_mlx5_mp"
#endif
uint8_t skip_default_rss_reta; /* Skip configuration of default reta. */
uint8_t fdb_def_rule; /* Whether fdb jump to table 1 is configured. */
+ struct mlx5_mp_id mp_id; /* ID of a multi-process process */
};
#define PORT_ID(priv) ((priv)->dev_data->port_id)
struct rte_flow_error *error);
/* mlx5_mp.c */
+int mlx5_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer);
+int mlx5_mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer);
void mlx5_mp_req_start_rxtx(struct rte_eth_dev *dev);
void mlx5_mp_req_stop_rxtx(struct rte_eth_dev *dev);
-int mlx5_mp_req_mr_create(struct rte_eth_dev *dev, uintptr_t addr);
-int mlx5_mp_req_verbs_cmd_fd(struct rte_eth_dev *dev);
-int mlx5_mp_req_queue_state_modify(struct rte_eth_dev *dev,
- struct mlx5_mp_arg_queue_state_modify *sm);
-int mlx5_mp_init_primary(void);
-void mlx5_mp_uninit_primary(void);
-int mlx5_mp_init_secondary(void);
-void mlx5_mp_uninit_secondary(void);
/* mlx5_socket.c */
#include <rte_ethdev_driver.h>
#include <rte_string_fns.h>
+#include <mlx5_common_mp.h>
+
#include "mlx5.h"
#include "mlx5_rxtx.h"
#include "mlx5_utils.h"
-/**
- * Initialize IPC message.
- *
- * @param[in] dev
- * Pointer to Ethernet structure.
- * @param[out] msg
- * Pointer to message to fill in.
- * @param[in] type
- * Message type.
- */
-static inline void
-mp_init_msg(struct rte_eth_dev *dev, 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, MLX5_MP_NAME, sizeof(msg->name));
- msg->len_param = sizeof(*param);
- param->type = type;
- param->port_id = dev->data->port_id;
-}
-
-/**
- * IPC message handler of primary process.
- *
- * @param[in] dev
- * Pointer to Ethernet structure.
- * @param[in] peer
- * Pointer to the peer socket path.
- *
- * @return
- * 0 on success, a negative errno value otherwise and rte_errno is set.
- */
-static int
-mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
+int
+mlx5_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
{
struct rte_mp_msg mp_res;
struct mlx5_mp_param *res = (struct mlx5_mp_param *)mp_res.param;
priv = dev->data->dev_private;
switch (param->type) {
case MLX5_MP_REQ_CREATE_MR:
- mp_init_msg(dev, &mp_res, param->type);
+ mp_init_msg(&priv->mp_id, &mp_res, param->type);
lkey = mlx5_mr_create_primary(dev, &entry, param->args.addr);
if (lkey == UINT32_MAX)
res->result = -rte_errno;
ret = rte_mp_reply(&mp_res, peer);
break;
case MLX5_MP_REQ_VERBS_CMD_FD:
- mp_init_msg(dev, &mp_res, param->type);
+ mp_init_msg(&priv->mp_id, &mp_res, param->type);
mp_res.num_fds = 1;
mp_res.fds[0] = priv->sh->ctx->cmd_fd;
res->result = 0;
ret = rte_mp_reply(&mp_res, peer);
break;
case MLX5_MP_REQ_QUEUE_STATE_MODIFY:
- mp_init_msg(dev, &mp_res, param->type);
+ mp_init_msg(&priv->mp_id, &mp_res, param->type);
res->result = mlx5_queue_state_modify_primary
(dev, ¶m->args.state_modify);
ret = rte_mp_reply(&mp_res, peer);
* @return
* 0 on success, a negative errno value otherwise and rte_errno is set.
*/
-static int
-mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
+int
+mlx5_mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
{
struct rte_mp_msg mp_res;
struct mlx5_mp_param *res = (struct mlx5_mp_param *)mp_res.param;
const struct mlx5_mp_param *param =
(const struct mlx5_mp_param *)mp_msg->param;
struct rte_eth_dev *dev;
+ struct mlx5_priv *priv;
int ret;
MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
return -rte_errno;
}
dev = &rte_eth_devices[param->port_id];
+ priv = dev->data->dev_private;
switch (param->type) {
case MLX5_MP_REQ_START_RXTX:
DRV_LOG(INFO, "port %u starting datapath", dev->data->port_id);
rte_mb();
dev->rx_pkt_burst = mlx5_select_rx_function(dev);
dev->tx_pkt_burst = mlx5_select_tx_function(dev);
- mp_init_msg(dev, &mp_res, param->type);
+ mp_init_msg(&priv->mp_id, &mp_res, param->type);
res->result = 0;
ret = rte_mp_reply(&mp_res, peer);
break;
dev->rx_pkt_burst = removed_rx_burst;
dev->tx_pkt_burst = removed_tx_burst;
rte_mb();
- mp_init_msg(dev, &mp_res, param->type);
+ mp_init_msg(&priv->mp_id, &mp_res, param->type);
res->result = 0;
ret = rte_mp_reply(&mp_res, peer);
break;
struct rte_mp_reply mp_rep;
struct mlx5_mp_param *res;
struct timespec ts = {.tv_sec = MLX5_MP_REQ_TIMEOUT_SEC, .tv_nsec = 0};
+ struct mlx5_priv *priv = dev->data->dev_private;
int ret;
int i;
dev->data->port_id, type);
return;
}
- mp_init_msg(dev, &mp_req, type);
+ mp_init_msg(&priv->mp_id, &mp_req, type);
ret = rte_mp_request_sync(&mp_req, &mp_rep, &ts);
if (ret) {
if (rte_errno != ENOTSUP)
{
mp_req_on_rxtx(dev, MLX5_MP_REQ_STOP_RXTX);
}
-
-/**
- * Request Memory Region creation to the primary process.
- *
- * @param[in] dev
- * Pointer to Ethernet structure.
- * @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 rte_eth_dev *dev, 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(dev, &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",
- dev->data->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] dev
- * Pointer to Ethernet structure.
- * @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 rte_eth_dev *dev,
- 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(dev, &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",
- dev->data->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] dev
- * Pointer to Ethernet structure.
- *
- * @return
- * fd on success, a negative errno value otherwise and rte_errno is set.
- */
-int
-mlx5_mp_req_verbs_cmd_fd(struct rte_eth_dev *dev)
-{
- 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(dev, &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",
- dev->data->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",
- dev->data->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",
- dev->data->port_id, ret);
-exit:
- free(mp_rep.msgs);
- return ret;
-}
-
-/**
- * Initialize by primary process.
- */
-int
-mlx5_mp_init_primary(void)
-{
- int ret;
-
- MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
-
- /* primary is allowed to not support IPC */
- ret = rte_mp_action_register(MLX5_MP_NAME, mp_primary_handle);
- if (ret && rte_errno != ENOTSUP)
- return -1;
- return 0;
-}
-
-/**
- * Un-initialize by primary process.
- */
-void
-mlx5_mp_uninit_primary(void)
-{
- MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
- rte_mp_action_unregister(MLX5_MP_NAME);
-}
-
-/**
- * Initialize by secondary process.
- */
-int
-mlx5_mp_init_secondary(void)
-{
- MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
- return rte_mp_action_register(MLX5_MP_NAME, mp_secondary_handle);
-}
-
-/**
- * Un-initialize by secondary process.
- */
-void
-mlx5_mp_uninit_secondary(void)
-{
- MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY);
- rte_mp_action_unregister(MLX5_MP_NAME);
-}
DEBUG("port %u requesting MR creation for address (%p)",
dev->data->port_id, (void *)addr);
- ret = mlx5_mp_req_mr_create(dev, addr);
+ ret = mlx5_mp_req_mr_create(&priv->mp_id, addr);
if (ret) {
DEBUG("port %u fail to request MR creation for address (%p)",
dev->data->port_id, (void *)addr);
mlx5_queue_state_modify(struct rte_eth_dev *dev,
struct mlx5_mp_arg_queue_state_modify *sm)
{
+ struct mlx5_priv *priv = dev->data->dev_private;
int ret = 0;
switch (rte_eal_process_type()) {
ret = mlx5_queue_state_modify_primary(dev, sm);
break;
case RTE_PROC_SECONDARY:
- ret = mlx5_mp_req_queue_state_modify(dev, sm);
+ ret = mlx5_mp_req_queue_state_modify(&priv->mp_id, sm);
break;
default:
break;