1
2
3
4
5
6#ifndef RTE_PMD_MLX5_COMMON_MP_H_
7#define RTE_PMD_MLX5_COMMON_MP_H_
8
9#include <mlx5_glue.h>
10#include <rte_eal.h>
11#include <rte_string_fns.h>
12
13
14enum 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,
26};
27
28struct mlx5_mp_arg_queue_state_modify {
29 uint8_t is_wq;
30 uint16_t queue_id;
31 enum ibv_wq_state state;
32};
33
34struct mlx5_mp_arg_queue_id {
35 uint16_t queue_id;
36};
37
38struct mlx5_mp_arg_mr_manage {
39 struct mlx5_common_device *cdev;
40 RTE_STD_C11
41 union {
42 struct {
43 struct rte_mempool *mempool;
44 bool is_extmem;
45 };
46 uintptr_t addr;
47 };
48};
49
50
51struct mlx5_mp_param {
52 enum mlx5_mp_req_type type;
53 int port_id;
54 int result;
55 RTE_STD_C11
56 union {
57 struct mlx5_mp_arg_mr_manage mr_manage;
58
59 struct mlx5_mp_arg_queue_state_modify state_modify;
60
61 struct mlx5_mp_arg_queue_id queue_id;
62
63 } args;
64};
65
66
67struct mlx5_mp_id {
68 char name[RTE_MP_MAX_NAME_LEN];
69 uint16_t port_id;
70};
71
72
73#define MLX5_MP_NAME "common_mlx5_mp"
74
75
76static inline void
77mlx5_mp_id_init(struct mlx5_mp_id *mp_id, uint16_t port_id)
78{
79 mp_id->port_id = port_id;
80 strlcpy(mp_id->name, MLX5_MP_NAME, RTE_MP_MAX_NAME_LEN);
81}
82
83
84#define MLX5_MP_REQ_TIMEOUT_SEC 5
85
86
87
88
89
90
91
92
93
94
95
96static inline void
97mp_init_msg(struct mlx5_mp_id *mp_id, struct rte_mp_msg *msg,
98 enum mlx5_mp_req_type type)
99{
100 struct mlx5_mp_param *param = (struct mlx5_mp_param *)msg->param;
101
102 memset(msg, 0, sizeof(*msg));
103 strlcpy(msg->name, mp_id->name, sizeof(msg->name));
104 msg->len_param = sizeof(*param);
105 param->type = type;
106 param->port_id = mp_id->port_id;
107}
108
109
110
111
112
113
114
115
116
117static inline void
118mp_init_port_agnostic_msg(struct rte_mp_msg *msg, enum mlx5_mp_req_type type)
119{
120 struct mlx5_mp_param *param = (struct mlx5_mp_param *)msg->param;
121
122 memset(msg, 0, sizeof(*msg));
123 strlcpy(msg->name, MLX5_MP_NAME, sizeof(msg->name));
124 msg->len_param = sizeof(*param);
125 param->type = type;
126}
127
128__rte_internal
129int mlx5_mp_init_primary(const char *name, const rte_mp_t primary_action);
130__rte_internal
131void mlx5_mp_uninit_primary(const char *name);
132__rte_internal
133int mlx5_mp_init_secondary(const char *name, const rte_mp_t secondary_action);
134__rte_internal
135void mlx5_mp_uninit_secondary(const char *name);
136__rte_internal
137int mlx5_mp_req_mr_create(struct mlx5_common_device *cdev, uintptr_t addr);
138__rte_internal
139int mlx5_mp_req_mempool_reg(struct mlx5_common_device *cdev,
140 struct rte_mempool *mempool, bool reg,
141 bool is_extmem);
142__rte_internal
143int mlx5_mp_req_queue_state_modify(struct mlx5_mp_id *mp_id,
144 struct mlx5_mp_arg_queue_state_modify *sm);
145__rte_internal
146int mlx5_mp_req_verbs_cmd_fd(struct mlx5_mp_id *mp_id);
147
148#endif
149