Roland Dreier | b2cbae2 | 2011-05-20 11:46:11 -0700 | [diff] [blame] | 1 | #ifndef _RDMA_NETLINK_H |
| 2 | #define _RDMA_NETLINK_H |
| 3 | |
Roland Dreier | b2cbae2 | 2011-05-20 11:46:11 -0700 | [diff] [blame] | 4 | |
| 5 | #include <linux/netlink.h> |
David Howells | 7235aa7 | 2012-11-21 15:47:40 +0000 | [diff] [blame] | 6 | #include <uapi/rdma/rdma_netlink.h> |
Roland Dreier | b2cbae2 | 2011-05-20 11:46:11 -0700 | [diff] [blame] | 7 | |
| 8 | struct ibnl_client_cbs { |
| 9 | int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb); |
Gao feng | 809d5fc | 2012-10-04 20:15:49 +0000 | [diff] [blame] | 10 | struct module *module; |
Roland Dreier | b2cbae2 | 2011-05-20 11:46:11 -0700 | [diff] [blame] | 11 | }; |
| 12 | |
Roland Dreier | b2cbae2 | 2011-05-20 11:46:11 -0700 | [diff] [blame] | 13 | /** |
| 14 | * Add a a client to the list of IB netlink exporters. |
| 15 | * @index: Index of the added client |
| 16 | * @nops: Number of supported ops by the added client. |
| 17 | * @cb_table: A table for op->callback |
| 18 | * |
| 19 | * Returns 0 on success or a negative error code. |
| 20 | */ |
| 21 | int ibnl_add_client(int index, int nops, |
| 22 | const struct ibnl_client_cbs cb_table[]); |
| 23 | |
| 24 | /** |
| 25 | * Remove a client from IB netlink. |
| 26 | * @index: Index of the removed IB client. |
| 27 | * |
| 28 | * Returns 0 on success or a negative error code. |
| 29 | */ |
| 30 | int ibnl_remove_client(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, |
Tatyana Nikolova | 30dc5e6 | 2014-03-26 17:07:35 -0500 | [diff] [blame] | 43 | int len, int client, int op, int flags); |
Roland Dreier | b2cbae2 | 2011-05-20 11:46:11 -0700 | [diff] [blame] | 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 | |
Tatyana Nikolova | 30dc5e6 | 2014-03-26 17:07:35 -0500 | [diff] [blame] | 56 | /** |
| 57 | * Send the supplied skb to a specific userspace PID. |
| 58 | * @skb: The netlink skb |
| 59 | * @nlh: Header of the netlink message to send |
| 60 | * @pid: Userspace netlink process ID |
| 61 | * Returns 0 on success or a negative error code. |
| 62 | */ |
| 63 | int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh, |
| 64 | __u32 pid); |
| 65 | |
| 66 | /** |
| 67 | * Send the supplied skb to a netlink group. |
| 68 | * @skb: The netlink skb |
| 69 | * @nlh: Header of the netlink message to send |
| 70 | * @group: Netlink group ID |
| 71 | * @flags: allocation flags |
| 72 | * Returns 0 on success or a negative error code. |
| 73 | */ |
| 74 | int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh, |
| 75 | unsigned int group, gfp_t flags); |
| 76 | |
Roland Dreier | b2cbae2 | 2011-05-20 11:46:11 -0700 | [diff] [blame] | 77 | #endif /* _RDMA_NETLINK_H */ |