16a94c425938e898ebab9e7dcec6d6ed4c1e7a56
[linux-block.git] / include / rdma / rdma_netlink.h
1 #ifndef _RDMA_NETLINK_H
2 #define _RDMA_NETLINK_H
3
4
5 #include <linux/netlink.h>
6 #include <uapi/rdma/rdma_netlink.h>
7
8 struct ibnl_client_cbs {
9         int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
10         u8 flags;
11 };
12
13 enum rdma_nl_flags {
14         /* Require CAP_NET_ADMIN */
15         RDMA_NL_ADMIN_PERM      = 1 << 0,
16 };
17
18 /**
19  * Register client in RDMA netlink.
20  * @index: Index of the added client
21  * @cb_table: A table for op->callback
22  */
23 void rdma_nl_register(unsigned int index,
24                       const struct ibnl_client_cbs cb_table[]);
25
26 /**
27  * Remove a client from IB netlink.
28  * @index: Index of the removed IB client.
29  */
30 void rdma_nl_unregister(unsigned int index);
31
32 /**
33  * Put a new message in a supplied skb.
34  * @skb: The netlink skb.
35  * @nlh: Pointer to put the header of the new netlink message.
36  * @seq: The message sequence number.
37  * @len: The requested message length to allocate.
38  * @client: Calling IB netlink client.
39  * @op: message content op.
40  * Returns the allocated buffer on success and NULL on failure.
41  */
42 void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
43                    int len, int client, int op, int flags);
44 /**
45  * Put a new attribute in a supplied skb.
46  * @skb: The netlink skb.
47  * @nlh: Header of the netlink message to append the attribute to.
48  * @len: The length of the attribute data.
49  * @data: The attribute data to put.
50  * @type: The attribute type.
51  * Returns the 0 and a negative error code on failure.
52  */
53 int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
54                   int len, void *data, int type);
55
56 /**
57  * Send the supplied skb to a specific userspace PID.
58  * @skb: The netlink skb
59  * @pid: Userspace netlink process ID
60  * Returns 0 on success or a negative error code.
61  */
62 int rdma_nl_unicast(struct sk_buff *skb, u32 pid);
63
64 /**
65  * Send, with wait/1 retry, the supplied skb to a specific userspace PID.
66  * @skb: The netlink skb
67  * @pid: Userspace netlink process ID
68  * Returns 0 on success or a negative error code.
69  */
70 int rdma_nl_unicast_wait(struct sk_buff *skb, __u32 pid);
71
72 /**
73  * Send the supplied skb to a netlink group.
74  * @skb: The netlink skb
75  * @group: Netlink group ID
76  * @flags: allocation flags
77  * Returns 0 on success or a negative error code.
78  */
79 int rdma_nl_multicast(struct sk_buff *skb, unsigned int group, gfp_t flags);
80
81 #endif /* _RDMA_NETLINK_H */