blob: 0790882e0c9b32443a37c44a26b3357224245d82 [file] [log] [blame]
Roland Dreierb2cbae22011-05-20 11:46:11 -07001#ifndef _RDMA_NETLINK_H
2#define _RDMA_NETLINK_H
3
Roland Dreierb2cbae22011-05-20 11:46:11 -07004
5#include <linux/netlink.h>
David Howells7235aa72012-11-21 15:47:40 +00006#include <uapi/rdma/rdma_netlink.h>
Roland Dreierb2cbae22011-05-20 11:46:11 -07007
8struct ibnl_client_cbs {
9 int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
Gao feng809d5fc2012-10-04 20:15:49 +000010 struct module *module;
Roland Dreierb2cbae22011-05-20 11:46:11 -070011};
12
13int ibnl_init(void);
14void ibnl_cleanup(void);
15
16/**
17 * Add a a client to the list of IB netlink exporters.
18 * @index: Index of the added client
19 * @nops: Number of supported ops by the added client.
20 * @cb_table: A table for op->callback
21 *
22 * Returns 0 on success or a negative error code.
23 */
24int ibnl_add_client(int index, int nops,
25 const struct ibnl_client_cbs cb_table[]);
26
27/**
28 * Remove a client from IB netlink.
29 * @index: Index of the removed IB client.
30 *
31 * Returns 0 on success or a negative error code.
32 */
33int ibnl_remove_client(int index);
34
35/**
36 * Put a new message in a supplied skb.
37 * @skb: The netlink skb.
38 * @nlh: Pointer to put the header of the new netlink message.
39 * @seq: The message sequence number.
40 * @len: The requested message length to allocate.
41 * @client: Calling IB netlink client.
42 * @op: message content op.
43 * Returns the allocated buffer on success and NULL on failure.
44 */
45void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
Tatyana Nikolova30dc5e62014-03-26 17:07:35 -050046 int len, int client, int op, int flags);
Roland Dreierb2cbae22011-05-20 11:46:11 -070047/**
48 * Put a new attribute in a supplied skb.
49 * @skb: The netlink skb.
50 * @nlh: Header of the netlink message to append the attribute to.
51 * @len: The length of the attribute data.
52 * @data: The attribute data to put.
53 * @type: The attribute type.
54 * Returns the 0 and a negative error code on failure.
55 */
56int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
57 int len, void *data, int type);
58
Tatyana Nikolova30dc5e62014-03-26 17:07:35 -050059/**
60 * Send the supplied skb to a specific userspace PID.
61 * @skb: The netlink skb
62 * @nlh: Header of the netlink message to send
63 * @pid: Userspace netlink process ID
64 * Returns 0 on success or a negative error code.
65 */
66int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
67 __u32 pid);
68
69/**
70 * Send the supplied skb to a netlink group.
71 * @skb: The netlink skb
72 * @nlh: Header of the netlink message to send
73 * @group: Netlink group ID
74 * @flags: allocation flags
75 * Returns 0 on success or a negative error code.
76 */
77int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh,
78 unsigned int group, gfp_t flags);
79
Roland Dreierb2cbae22011-05-20 11:46:11 -070080#endif /* _RDMA_NETLINK_H */