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