]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/rdma/rdma_netlink.h
Linux 4.14-rc6
[mirror_ubuntu-bionic-kernel.git] / include / rdma / rdma_netlink.h
CommitLineData
b2cbae2c
RD
1#ifndef _RDMA_NETLINK_H
2#define _RDMA_NETLINK_H
3
b2cbae2c
RD
4
5#include <linux/netlink.h>
7235aa79 6#include <uapi/rdma/rdma_netlink.h>
b2cbae2c 7
3250b4db 8struct rdma_nl_cbs {
1830ba21
LR
9 int (*doit)(struct sk_buff *skb, struct nlmsghdr *nlh,
10 struct netlink_ext_ack *extack);
b2cbae2c 11 int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
e3a2b93d
LR
12 u8 flags;
13};
14
15enum rdma_nl_flags {
16 /* Require CAP_NET_ADMIN */
17 RDMA_NL_ADMIN_PERM = 1 << 0,
b2cbae2c
RD
18};
19
e3bf14bd
JG
20/* Define this module as providing netlink services for NETLINK_RDMA, with
21 * index _index. Since the client indexes were setup in a uapi header as an
22 * enum and we do no want to change that, the user must supply the expanded
23 * constant as well and the compiler checks they are the same.
24 */
25#define MODULE_ALIAS_RDMA_NETLINK(_index, _val) \
26 static inline void __chk_##_index(void) \
27 { \
28 BUILD_BUG_ON(_index != _val); \
29 } \
30 MODULE_ALIAS("rdma-netlink-subsys-" __stringify(_val))
31
b2cbae2c 32/**
c9901724 33 * Register client in RDMA netlink.
b2cbae2c 34 * @index: Index of the added client
b2cbae2c 35 * @cb_table: A table for op->callback
b2cbae2c 36 */
c9901724 37void rdma_nl_register(unsigned int index,
3250b4db 38 const struct rdma_nl_cbs cb_table[]);
b2cbae2c
RD
39
40/**
41 * Remove a client from IB netlink.
42 * @index: Index of the removed IB client.
b2cbae2c 43 */
c9901724 44void rdma_nl_unregister(unsigned int index);
b2cbae2c
RD
45
46/**
47 * Put a new message in a supplied skb.
48 * @skb: The netlink skb.
49 * @nlh: Pointer to put the header of the new netlink message.
50 * @seq: The message sequence number.
51 * @len: The requested message length to allocate.
52 * @client: Calling IB netlink client.
53 * @op: message content op.
54 * Returns the allocated buffer on success and NULL on failure.
55 */
56void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
30dc5e63 57 int len, int client, int op, int flags);
b2cbae2c
RD
58/**
59 * Put a new attribute in a supplied skb.
60 * @skb: The netlink skb.
61 * @nlh: Header of the netlink message to append the attribute to.
62 * @len: The length of the attribute data.
63 * @data: The attribute data to put.
64 * @type: The attribute type.
65 * Returns the 0 and a negative error code on failure.
66 */
67int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
68 int len, void *data, int type);
69
30dc5e63
TN
70/**
71 * Send the supplied skb to a specific userspace PID.
72 * @skb: The netlink skb
30dc5e63
TN
73 * @pid: Userspace netlink process ID
74 * Returns 0 on success or a negative error code.
75 */
f00e6463 76int rdma_nl_unicast(struct sk_buff *skb, u32 pid);
30dc5e63 77
9047811b
IM
78/**
79 * Send, with wait/1 retry, the supplied skb to a specific userspace PID.
80 * @skb: The netlink skb
9047811b
IM
81 * @pid: Userspace netlink process ID
82 * Returns 0 on success or a negative error code.
83 */
f00e6463 84int rdma_nl_unicast_wait(struct sk_buff *skb, __u32 pid);
9047811b 85
30dc5e63
TN
86/**
87 * Send the supplied skb to a netlink group.
88 * @skb: The netlink skb
30dc5e63
TN
89 * @group: Netlink group ID
90 * @flags: allocation flags
91 * Returns 0 on success or a negative error code.
92 */
4d7f693a 93int rdma_nl_multicast(struct sk_buff *skb, unsigned int group, gfp_t flags);
30dc5e63 94
ff61c425
LR
95/**
96 * Check if there are any listeners to the netlink group
97 * @group: the netlink group ID
98 * Returns 0 on success or a negative for no listeners.
99 */
100int rdma_nl_chk_listeners(unsigned int group);
b2cbae2c 101#endif /* _RDMA_NETLINK_H */