]> git.proxmox.com Git - mirror_iproute2.git/blob - rdma/res.h
rdma: Move out resource CQ logic to separate file
[mirror_iproute2.git] / rdma / res.h
1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /*
3 * res.h RDMA tool
4 * Authors: Leon Romanovsky <leonro@mellanox.com>
5 */
6 #ifndef _RDMA_TOOL_RES_H_
7 #define _RDMA_TOOL_RES_H_
8
9 #include "rdma.h"
10
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);
13 int res_mr_parse_cb(const struct nlmsghdr *nlh, void *data);
14 int res_cq_parse_cb(const struct nlmsghdr *nlh, void *data);
15
16 #define RES_FUNC(name, command, valid_filters, strict_port) \
17 static inline int _##name(struct rd *rd)\
18 { \
19 return _res_send_msg(rd, command, name##_parse_cb); \
20 } \
21 static inline int name(struct rd *rd) \
22 {\
23 int ret = rd_build_filter(rd, valid_filters); \
24 if (ret) \
25 return ret; \
26 if ((uintptr_t)valid_filters != (uintptr_t)NULL) { \
27 ret = rd_set_arg_to_devname(rd); \
28 if (ret) \
29 return ret;\
30 } \
31 if (strict_port) \
32 return rd_exec_dev(rd, _##name); \
33 else \
34 return rd_exec_link(rd, _##name, strict_port); \
35 }
36
37 static const
38 struct filters pd_valid_filters[MAX_NUMBER_OF_FILTERS] = {
39 { .name = "dev", .is_number = false },
40 { .name = "users", .is_number = true },
41 { .name = "pid", .is_number = true },
42 { .name = "ctxn", .is_number = true },
43 { .name = "pdn", .is_number = true },
44 { .name = "ctxn", .is_number = true }
45 };
46
47 RES_FUNC(res_pd, RDMA_NLDEV_CMD_RES_PD_GET, pd_valid_filters, true);
48
49 static const
50 struct filters mr_valid_filters[MAX_NUMBER_OF_FILTERS] = {
51 { .name = "dev", .is_number = false },
52 { .name = "rkey", .is_number = true },
53 { .name = "lkey", .is_number = true },
54 { .name = "mrlen", .is_number = true },
55 { .name = "pid", .is_number = true },
56 { .name = "mrn", .is_number = true },
57 { .name = "pdn", .is_number = true }
58 };
59
60 RES_FUNC(res_mr, RDMA_NLDEV_CMD_RES_MR_GET, mr_valid_filters, true);
61
62 static const
63 struct filters cq_valid_filters[MAX_NUMBER_OF_FILTERS] = {
64 { .name = "dev", .is_number = false },
65 { .name = "users", .is_number = true },
66 { .name = "poll-ctx", .is_number = false },
67 { .name = "pid", .is_number = true },
68 { .name = "cqn", .is_number = true },
69 { .name = "ctxn", .is_number = true }
70 };
71
72 RES_FUNC(res_cq, RDMA_NLDEV_CMD_RES_CQ_GET, cq_valid_filters, true);
73
74 char *get_task_name(uint32_t pid);
75 void print_dev(struct rd *rd, uint32_t idx, const char *name);
76 void print_users(struct rd *rd, uint64_t val);
77 void print_key(struct rd *rd, const char *name, uint64_t val);
78 void res_print_uint(struct rd *rd, const char *name, uint64_t val);
79 void print_pid(struct rd *rd, uint32_t val);
80 void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line);
81
82 #endif /* _RDMA_TOOL_RES_H_ */