Commit | Line | Data |
---|---|---|
b2cbae2c RD |
1 | #ifndef _RDMA_NETLINK_H |
2 | #define _RDMA_NETLINK_H | |
3 | ||
753f618a NM |
4 | #include <linux/types.h> |
5 | ||
6 | enum { | |
7 | RDMA_NL_RDMA_CM = 1 | |
8 | }; | |
9 | ||
b2cbae2c RD |
10 | #define RDMA_NL_GET_CLIENT(type) ((type & (((1 << 6) - 1) << 10)) >> 10) |
11 | #define RDMA_NL_GET_OP(type) (type & ((1 << 10) - 1)) | |
12 | #define RDMA_NL_GET_TYPE(client, op) ((client << 10) + op) | |
13 | ||
753f618a NM |
14 | enum { |
15 | RDMA_NL_RDMA_CM_ID_STATS = 0, | |
16 | RDMA_NL_RDMA_CM_NUM_OPS | |
17 | }; | |
18 | ||
19 | enum { | |
20 | RDMA_NL_RDMA_CM_ATTR_SRC_ADDR = 1, | |
21 | RDMA_NL_RDMA_CM_ATTR_DST_ADDR, | |
22 | RDMA_NL_RDMA_CM_NUM_ATTR, | |
23 | }; | |
24 | ||
25 | struct rdma_cm_id_stats { | |
26 | __u32 qp_num; | |
27 | __u32 bound_dev_if; | |
28 | __u32 port_space; | |
29 | __s32 pid; | |
30 | __u8 cm_state; | |
31 | __u8 node_type; | |
32 | __u8 port_num; | |
33 | __u8 qp_type; | |
34 | }; | |
35 | ||
b2cbae2c RD |
36 | #ifdef __KERNEL__ |
37 | ||
38 | #include <linux/netlink.h> | |
39 | ||
40 | struct ibnl_client_cbs { | |
41 | int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb); | |
809d5fc9 | 42 | struct module *module; |
b2cbae2c RD |
43 | }; |
44 | ||
45 | int ibnl_init(void); | |
46 | void ibnl_cleanup(void); | |
47 | ||
48 | /** | |
49 | * Add a a client to the list of IB netlink exporters. | |
50 | * @index: Index of the added client | |
51 | * @nops: Number of supported ops by the added client. | |
52 | * @cb_table: A table for op->callback | |
53 | * | |
54 | * Returns 0 on success or a negative error code. | |
55 | */ | |
56 | int ibnl_add_client(int index, int nops, | |
57 | const struct ibnl_client_cbs cb_table[]); | |
58 | ||
59 | /** | |
60 | * Remove a client from IB netlink. | |
61 | * @index: Index of the removed IB client. | |
62 | * | |
63 | * Returns 0 on success or a negative error code. | |
64 | */ | |
65 | int ibnl_remove_client(int index); | |
66 | ||
67 | /** | |
68 | * Put a new message in a supplied skb. | |
69 | * @skb: The netlink skb. | |
70 | * @nlh: Pointer to put the header of the new netlink message. | |
71 | * @seq: The message sequence number. | |
72 | * @len: The requested message length to allocate. | |
73 | * @client: Calling IB netlink client. | |
74 | * @op: message content op. | |
75 | * Returns the allocated buffer on success and NULL on failure. | |
76 | */ | |
77 | void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq, | |
78 | int len, int client, int op); | |
79 | /** | |
80 | * Put a new attribute in a supplied skb. | |
81 | * @skb: The netlink skb. | |
82 | * @nlh: Header of the netlink message to append the attribute to. | |
83 | * @len: The length of the attribute data. | |
84 | * @data: The attribute data to put. | |
85 | * @type: The attribute type. | |
86 | * Returns the 0 and a negative error code on failure. | |
87 | */ | |
88 | int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh, | |
89 | int len, void *data, int type); | |
90 | ||
91 | #endif /* __KERNEL__ */ | |
92 | ||
93 | #endif /* _RDMA_NETLINK_H */ |