]>
git.proxmox.com Git - mirror_iproute2.git/blob - rdma/rdma.h
1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
4 * Authors: Leon Romanovsky <leonro@mellanox.com>
13 #include <netinet/in.h>
14 #include <libmnl/libmnl.h>
15 #include <rdma/rdma_netlink.h>
16 #include <rdma/rdma_user_cm.h>
18 #include <net/if_arp.h>
22 #include "json_print.h"
24 #define pr_err(args...) fprintf(stderr, ##args)
25 #define pr_out(args...) fprintf(stdout, ##args)
27 #define RDMA_BITMAP_ENUM(name, bit_no) RDMA_BITMAP_##name = BIT(bit_no),
28 #define RDMA_BITMAP_NAMES(name, bit_no) [bit_no] = #name,
30 #define MAX_NUMBER_OF_FILTERS 64
38 struct list_head list
;
42 * This field menas that we can try to issue .doit calback
43 * on value above. This value can be converted to integer
44 * with simple atoi(). Otherwise "is_doit" will be false.
50 struct list_head list
;
60 uint8_t show_details
:1;
61 uint8_t show_driver_details
:1;
63 struct list_head dev_map_list
;
66 struct mnl_socket
*nl
;
73 struct list_head filter_list
;
80 int (*func
)(struct rd
*rd
);
86 bool rd_no_arg(struct rd
*rd
);
87 void rd_arg_inc(struct rd
*rd
);
89 char *rd_argv(struct rd
*rd
);
94 int cmd_dev(struct rd
*rd
);
95 int cmd_link(struct rd
*rd
);
96 int cmd_res(struct rd
*rd
);
97 int cmd_sys(struct rd
*rd
);
98 int cmd_stat(struct rd
*rd
);
99 int rd_exec_cmd(struct rd
*rd
, const struct rd_cmd
*c
, const char *str
);
100 int rd_exec_dev(struct rd
*rd
, int (*cb
)(struct rd
*rd
));
101 int rd_exec_require_dev(struct rd
*rd
, int (*cb
)(struct rd
*rd
));
102 int rd_exec_link(struct rd
*rd
, int (*cb
)(struct rd
*rd
), bool strict_port
);
103 void rd_free(struct rd
*rd
);
104 int rd_set_arg_to_devname(struct rd
*rd
);
105 int rd_argc(struct rd
*rd
);
107 int strcmpx(const char *str1
, const char *str2
);
110 * Device manipulation
112 struct dev_map
*dev_map_lookup(struct rd
*rd
, bool allow_port_index
);
115 * Filter manipulation
117 bool rd_doit_index(struct rd
*rd
, uint32_t *idx
);
118 int rd_build_filter(struct rd
*rd
, const struct filters valid_filters
[]);
119 bool rd_is_filtered_attr(struct rd
*rd
, const char *key
, uint32_t val
,
120 struct nlattr
*attr
);
121 bool rd_is_string_filtered_attr(struct rd
*rd
, const char *key
, const char *val
,
122 struct nlattr
*attr
);
126 int rd_send_msg(struct rd
*rd
);
127 int rd_recv_msg(struct rd
*rd
, mnl_cb_t callback
, void *data
, uint32_t seq
);
128 int rd_sendrecv_msg(struct rd
*rd
, unsigned int seq
);
129 void rd_prepare_msg(struct rd
*rd
, uint32_t cmd
, uint32_t *seq
, uint16_t flags
);
130 int rd_dev_init_cb(const struct nlmsghdr
*nlh
, void *data
);
131 int rd_attr_cb(const struct nlattr
*attr
, void *data
);
132 int rd_attr_check(const struct nlattr
*attr
, int *typep
);
137 void print_driver_table(struct rd
*rd
, struct nlattr
*tb
);
138 void print_raw_data(struct rd
*rd
, struct nlattr
**nla_line
);
139 void newline(struct rd
*rd
);
140 void newline_indent(struct rd
*rd
);
141 void print_on_off(struct rd
*rd
, const char *key_str
, bool on
);
142 void print_raw_data(struct rd
*rd
, struct nlattr
**nla_line
);
143 #define MAX_LINE_LENGTH 80
145 #endif /* _RDMA_TOOL_H_ */