1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
4 * Authors: Leon Romanovsky <leonro@mellanox.com>
6 #ifndef _RDMA_TOOL_RES_H_
7 #define _RDMA_TOOL_RES_H_
11 int _res_send_msg(struct rd
*rd
, uint32_t command
, mnl_cb_t callback
);
12 int res_pd_parse_cb(const struct nlmsghdr
*nlh
, void *data
);
14 #define RES_FUNC(name, command, valid_filters, strict_port) \
15 static inline int _##name(struct rd *rd)\
17 return _res_send_msg(rd, command, name##_parse_cb); \
19 static inline int name(struct rd *rd) \
21 int ret = rd_build_filter(rd, valid_filters); \
24 if ((uintptr_t)valid_filters != (uintptr_t)NULL) { \
25 ret = rd_set_arg_to_devname(rd); \
30 return rd_exec_dev(rd, _##name); \
32 return rd_exec_link(rd, _##name, strict_port); \
36 struct filters pd_valid_filters
[MAX_NUMBER_OF_FILTERS
] = {
37 { .name
= "dev", .is_number
= false },
38 { .name
= "users", .is_number
= true },
39 { .name
= "pid", .is_number
= true },
40 { .name
= "ctxn", .is_number
= true },
41 { .name
= "pdn", .is_number
= true },
42 { .name
= "ctxn", .is_number
= true }
45 RES_FUNC(res_pd
, RDMA_NLDEV_CMD_RES_PD_GET
, pd_valid_filters
, true);
47 char *get_task_name(uint32_t pid
);
48 void print_dev(struct rd
*rd
, uint32_t idx
, const char *name
);
49 void print_users(struct rd
*rd
, uint64_t val
);
50 void print_key(struct rd
*rd
, const char *name
, uint64_t val
);
51 void res_print_uint(struct rd
*rd
, const char *name
, uint64_t val
);
52 void print_pid(struct rd
*rd
, uint32_t val
);
53 void print_comm(struct rd
*rd
, const char *str
, struct nlattr
**nla_line
);
55 #endif /* _RDMA_TOOL_RES_H_ */