1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 6WIND S.A.
3 * Copyright 2018 Mellanox Technologies, Ltd
6 #ifndef RTE_PMD_MLX5_COMMON_MP_H_
7 #define RTE_PMD_MLX5_COMMON_MP_H_
11 #include <rte_string_fns.h>
13 /* Request types for IPC. */
14 enum mlx5_mp_req_type {
15 MLX5_MP_REQ_VERBS_CMD_FD = 1,
16 MLX5_MP_REQ_CREATE_MR,
17 MLX5_MP_REQ_MEMPOOL_REGISTER,
18 MLX5_MP_REQ_MEMPOOL_UNREGISTER,
19 MLX5_MP_REQ_START_RXTX,
20 MLX5_MP_REQ_STOP_RXTX,
21 MLX5_MP_REQ_QUEUE_STATE_MODIFY,
22 MLX5_MP_REQ_QUEUE_RX_STOP,
23 MLX5_MP_REQ_QUEUE_RX_START,
24 MLX5_MP_REQ_QUEUE_TX_STOP,
25 MLX5_MP_REQ_QUEUE_TX_START,
28 struct mlx5_mp_arg_queue_state_modify {
29 uint8_t is_wq; /* Set if WQ. */
30 uint16_t queue_id; /* DPDK queue ID. */
31 enum ibv_wq_state state; /* WQ requested state. */
34 struct mlx5_mp_arg_queue_id {
35 uint16_t queue_id; /* DPDK queue ID. */
38 struct mlx5_mp_arg_mr_manage {
39 struct mlx5_common_device *cdev;
43 struct rte_mempool *mempool;
45 }; /* MLX5_MP_REQ_MEMPOOL_(UN)REGISTER */
46 uintptr_t addr; /* MLX5_MP_REQ_CREATE_MR */
50 /* Parameters for IPC. */
51 struct mlx5_mp_param {
52 enum mlx5_mp_req_type type;
57 struct mlx5_mp_arg_mr_manage mr_manage;
58 /* MLX5_MP_REQ_MEMPOOL_(UN)REGISTER, MLX5_MP_REQ_CREATE_MR */
59 struct mlx5_mp_arg_queue_state_modify state_modify;
60 /* MLX5_MP_REQ_QUEUE_STATE_MODIFY */
61 struct mlx5_mp_arg_queue_id queue_id;
62 /* MLX5_MP_REQ_QUEUE_RX/TX_START/STOP */
66 /* Identifier of a MP process */
68 char name[RTE_MP_MAX_NAME_LEN];
72 /** Key string for IPC. */
73 #define MLX5_MP_NAME "common_mlx5_mp"
75 /** Initialize a multi-process ID. */
77 mlx5_mp_id_init(struct mlx5_mp_id *mp_id, uint16_t port_id)
79 mp_id->port_id = port_id;
80 strlcpy(mp_id->name, MLX5_MP_NAME, RTE_MP_MAX_NAME_LEN);
83 /** Request timeout for IPC. */
84 #define MLX5_MP_REQ_TIMEOUT_SEC 5
87 * Initialize IPC message.
90 * Port ID of the device.
92 * Pointer to message to fill in.
97 mp_init_msg(struct mlx5_mp_id *mp_id, struct rte_mp_msg *msg,
98 enum mlx5_mp_req_type type)
100 struct mlx5_mp_param *param = (struct mlx5_mp_param *)msg->param;
102 memset(msg, 0, sizeof(*msg));
103 strlcpy(msg->name, mp_id->name, sizeof(msg->name));
104 msg->len_param = sizeof(*param);
106 param->port_id = mp_id->port_id;
110 * Initialize IPC port-agnostic message.
113 * Pointer to message to fill in.
118 mp_init_port_agnostic_msg(struct rte_mp_msg *msg, enum mlx5_mp_req_type type)
120 struct mlx5_mp_param *param = (struct mlx5_mp_param *)msg->param;
122 memset(msg, 0, sizeof(*msg));
123 strlcpy(msg->name, MLX5_MP_NAME, sizeof(msg->name));
124 msg->len_param = sizeof(*param);
129 int mlx5_mp_init_primary(const char *name, const rte_mp_t primary_action);
131 void mlx5_mp_uninit_primary(const char *name);
133 int mlx5_mp_init_secondary(const char *name, const rte_mp_t secondary_action);
135 void mlx5_mp_uninit_secondary(const char *name);
137 int mlx5_mp_req_mr_create(struct mlx5_common_device *cdev, uintptr_t addr);
139 int mlx5_mp_req_mempool_reg(struct mlx5_common_device *cdev,
140 struct rte_mempool *mempool, bool reg,
143 int mlx5_mp_req_queue_state_modify(struct mlx5_mp_id *mp_id,
144 struct mlx5_mp_arg_queue_state_modify *sm);
146 int mlx5_mp_req_verbs_cmd_fd(struct mlx5_mp_id *mp_id);
148 #endif /* RTE_PMD_MLX5_COMMON_MP_H_ */