]> Pileus Git - ~andy/linux/blob - include/rdma/rdma_netlink.h
RDMA: Add netlink infrastructure
[~andy/linux] / include / rdma / rdma_netlink.h
1 #ifndef _RDMA_NETLINK_H
2 #define _RDMA_NETLINK_H
3
4 #define RDMA_NL_GET_CLIENT(type) ((type & (((1 << 6) - 1) << 10)) >> 10)
5 #define RDMA_NL_GET_OP(type) (type & ((1 << 10) - 1))
6 #define RDMA_NL_GET_TYPE(client, op) ((client << 10) + op)
7
8 #ifdef __KERNEL__
9
10 #include <linux/netlink.h>
11
12 struct ibnl_client_cbs {
13         int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
14 };
15
16 int ibnl_init(void);
17 void ibnl_cleanup(void);
18
19 /**
20  * Add a a client to the list of IB netlink exporters.
21  * @index: Index of the added client
22  * @nops: Number of supported ops by the added client.
23  * @cb_table: A table for op->callback
24  *
25  * Returns 0 on success or a negative error code.
26  */
27 int ibnl_add_client(int index, int nops,
28                     const struct ibnl_client_cbs cb_table[]);
29
30 /**
31  * Remove a client from IB netlink.
32  * @index: Index of the removed IB client.
33  *
34  * Returns 0 on success or a negative error code.
35  */
36 int ibnl_remove_client(int index);
37
38 /**
39  * Put a new message in a supplied skb.
40  * @skb: The netlink skb.
41  * @nlh: Pointer to put the header of the new netlink message.
42  * @seq: The message sequence number.
43  * @len: The requested message length to allocate.
44  * @client: Calling IB netlink client.
45  * @op: message content op.
46  * Returns the allocated buffer on success and NULL on failure.
47  */
48 void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
49                    int len, int client, int op);
50 /**
51  * Put a new attribute in a supplied skb.
52  * @skb: The netlink skb.
53  * @nlh: Header of the netlink message to append the attribute to.
54  * @len: The length of the attribute data.
55  * @data: The attribute data to put.
56  * @type: The attribute type.
57  * Returns the 0 and a negative error code on failure.
58  */
59 int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
60                   int len, void *data, int type);
61
62 #endif /* __KERNEL__ */
63
64 #endif /* _RDMA_NETLINK_H */