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