]> git.proxmox.com Git - mirror_iproute2.git/blame - rdma/rdma.h
Merge branch 'iproute2-master' into iproute2-next
[mirror_iproute2.git] / rdma / rdma.h
CommitLineData
74bd75c2
LR
1/*
2 * rdma.c RDMA tool
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * Authors: Leon Romanovsky <leonro@mellanox.com>
10 */
11#ifndef _RDMA_TOOL_H_
12#define _RDMA_TOOL_H_
13
14#include <stdlib.h>
15#include <string.h>
16#include <errno.h>
17#include <getopt.h>
5887ff09 18#include <netinet/in.h>
74bd75c2
LR
19#include <libmnl/libmnl.h>
20#include <rdma/rdma_netlink.h>
9a362cc7 21#include <rdma/rdma_user_cm.h>
74bd75c2 22#include <time.h>
9a362cc7 23#include <net/if_arp.h>
74bd75c2
LR
24
25#include "list.h"
40df8263 26#include "utils.h"
ab6e2b7b 27#include "json_writer.h"
74bd75c2
LR
28
29#define pr_err(args...) fprintf(stderr, ##args)
30#define pr_out(args...) fprintf(stdout, ##args)
31
40df8263
LR
32#define RDMA_BITMAP_ENUM(name, bit_no) RDMA_BITMAP_##name = BIT(bit_no),
33#define RDMA_BITMAP_NAMES(name, bit_no) [bit_no] = #name,
34
1174be72
LR
35#define MAX_NUMBER_OF_FILTERS 64
36struct filters {
3b0070f6 37 const char *name;
1174be72
LR
38 bool is_number;
39};
40
41struct filter_entry {
42 struct list_head list;
43 char *key;
44 char *value;
45};
46
74bd75c2
LR
47struct dev_map {
48 struct list_head list;
49 char *dev_name;
50 uint32_t num_ports;
51 uint32_t idx;
52};
53
54struct rd {
55 int argc;
56 char **argv;
57 char *filename;
58 bool show_details;
33115275 59 bool show_driver_details;
74bd75c2 60 struct list_head dev_map_list;
40df8263
LR
61 uint32_t dev_idx;
62 uint32_t port_idx;
74bd75c2
LR
63 struct mnl_socket *nl;
64 struct nlmsghdr *nlh;
65 char *buff;
ab6e2b7b
LR
66 json_writer_t *jw;
67 bool json_output;
68 bool pretty_output;
1174be72 69 struct list_head filter_list;
74bd75c2
LR
70};
71
72struct rd_cmd {
73 const char *cmd;
74 int (*func)(struct rd *rd);
75};
76
40df8263 77
40df8263
LR
78/*
79 * Commands interface
80 */
81int cmd_dev(struct rd *rd);
82int cmd_link(struct rd *rd);
923aa825 83int cmd_res(struct rd *rd);
74bd75c2 84int rd_exec_cmd(struct rd *rd, const struct rd_cmd *c, const char *str);
8b92a2c9 85int rd_exec_dev(struct rd *rd, int (*cb)(struct rd *rd));
a14ceed3 86int rd_exec_require_dev(struct rd *rd, int (*cb)(struct rd *rd));
6416d1a0 87int rd_exec_link(struct rd *rd, int (*cb)(struct rd *rd), bool strict_port);
5fc17280 88void rd_free(struct rd *rd);
6e0de6e8 89int rd_set_arg_to_devname(struct rd *rd);
5f4892e2 90int rd_argc(struct rd *rd);
74bd75c2
LR
91
92/*
93 * Device manipulation
94 */
40df8263 95struct dev_map *dev_map_lookup(struct rd *rd, bool allow_port_index);
74bd75c2 96
1174be72
LR
97/*
98 * Filter manipulation
99 */
100int rd_build_filter(struct rd *rd, const struct filters valid_filters[]);
101bool rd_check_is_filtered(struct rd *rd, const char *key, uint32_t val);
102bool rd_check_is_string_filtered(struct rd *rd, const char *key, const char *val);
103bool rd_check_is_key_exist(struct rd *rd, const char *key);
74bd75c2
LR
104/*
105 * Netlink
106 */
107int rd_send_msg(struct rd *rd);
108int rd_recv_msg(struct rd *rd, mnl_cb_t callback, void *data, uint32_t seq);
109void rd_prepare_msg(struct rd *rd, uint32_t cmd, uint32_t *seq, uint16_t flags);
110int rd_dev_init_cb(const struct nlmsghdr *nlh, void *data);
111int rd_attr_cb(const struct nlattr *attr, void *data);
33115275
SW
112
113/*
114 * Print helpers
115 */
116void print_driver_table(struct rd *rd, struct nlattr *tb);
117void newline(struct rd *rd);
33115275
SW
118#define MAX_LINE_LENGTH 80
119
74bd75c2 120#endif /* _RDMA_TOOL_H_ */