xref: /linux/include/rdma/rdma_netlink.h (revision 1830ba21)
1b2cbae2cSRoland Dreier #ifndef _RDMA_NETLINK_H
2b2cbae2cSRoland Dreier #define _RDMA_NETLINK_H
3b2cbae2cSRoland Dreier 
4b2cbae2cSRoland Dreier 
5b2cbae2cSRoland Dreier #include <linux/netlink.h>
67235aa79SDavid Howells #include <uapi/rdma/rdma_netlink.h>
7b2cbae2cSRoland Dreier 
83250b4dbSLeon Romanovsky struct rdma_nl_cbs {
9*1830ba21SLeon Romanovsky 	int (*doit)(struct sk_buff *skb, struct nlmsghdr *nlh,
10*1830ba21SLeon Romanovsky 		    struct netlink_ext_ack *extack);
11b2cbae2cSRoland Dreier 	int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
12e3a2b93dSLeon Romanovsky 	u8 flags;
13e3a2b93dSLeon Romanovsky };
14e3a2b93dSLeon Romanovsky 
15e3a2b93dSLeon Romanovsky enum rdma_nl_flags {
16e3a2b93dSLeon Romanovsky 	/* Require CAP_NET_ADMIN */
17e3a2b93dSLeon Romanovsky 	RDMA_NL_ADMIN_PERM	= 1 << 0,
18b2cbae2cSRoland Dreier };
19b2cbae2cSRoland Dreier 
20b2cbae2cSRoland Dreier /**
21c9901724SLeon Romanovsky  * Register client in RDMA netlink.
22b2cbae2cSRoland Dreier  * @index: Index of the added client
23b2cbae2cSRoland Dreier  * @cb_table: A table for op->callback
24b2cbae2cSRoland Dreier  */
25c9901724SLeon Romanovsky void rdma_nl_register(unsigned int index,
263250b4dbSLeon Romanovsky 		      const struct rdma_nl_cbs cb_table[]);
27b2cbae2cSRoland Dreier 
28b2cbae2cSRoland Dreier /**
29b2cbae2cSRoland Dreier  * Remove a client from IB netlink.
30b2cbae2cSRoland Dreier  * @index: Index of the removed IB client.
31b2cbae2cSRoland Dreier  */
32c9901724SLeon Romanovsky void rdma_nl_unregister(unsigned int index);
33b2cbae2cSRoland Dreier 
34b2cbae2cSRoland Dreier /**
35b2cbae2cSRoland Dreier  * Put a new message in a supplied skb.
36b2cbae2cSRoland Dreier  * @skb: The netlink skb.
37b2cbae2cSRoland Dreier  * @nlh: Pointer to put the header of the new netlink message.
38b2cbae2cSRoland Dreier  * @seq: The message sequence number.
39b2cbae2cSRoland Dreier  * @len: The requested message length to allocate.
40b2cbae2cSRoland Dreier  * @client: Calling IB netlink client.
41b2cbae2cSRoland Dreier  * @op: message content op.
42b2cbae2cSRoland Dreier  * Returns the allocated buffer on success and NULL on failure.
43b2cbae2cSRoland Dreier  */
44b2cbae2cSRoland Dreier void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
4530dc5e63STatyana Nikolova 		   int len, int client, int op, int flags);
46b2cbae2cSRoland Dreier /**
47b2cbae2cSRoland Dreier  * Put a new attribute in a supplied skb.
48b2cbae2cSRoland Dreier  * @skb: The netlink skb.
49b2cbae2cSRoland Dreier  * @nlh: Header of the netlink message to append the attribute to.
50b2cbae2cSRoland Dreier  * @len: The length of the attribute data.
51b2cbae2cSRoland Dreier  * @data: The attribute data to put.
52b2cbae2cSRoland Dreier  * @type: The attribute type.
53b2cbae2cSRoland Dreier  * Returns the 0 and a negative error code on failure.
54b2cbae2cSRoland Dreier  */
55b2cbae2cSRoland Dreier int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
56b2cbae2cSRoland Dreier 		  int len, void *data, int type);
57b2cbae2cSRoland Dreier 
5830dc5e63STatyana Nikolova /**
5930dc5e63STatyana Nikolova  * Send the supplied skb to a specific userspace PID.
6030dc5e63STatyana Nikolova  * @skb: The netlink skb
6130dc5e63STatyana Nikolova  * @pid: Userspace netlink process ID
6230dc5e63STatyana Nikolova  * Returns 0 on success or a negative error code.
6330dc5e63STatyana Nikolova  */
64f00e6463SLeon Romanovsky int rdma_nl_unicast(struct sk_buff *skb, u32 pid);
6530dc5e63STatyana Nikolova 
6630dc5e63STatyana Nikolova /**
679047811bSIsmail, Mustafa  * Send, with wait/1 retry, the supplied skb to a specific userspace PID.
689047811bSIsmail, Mustafa  * @skb: The netlink skb
699047811bSIsmail, Mustafa  * @pid: Userspace netlink process ID
709047811bSIsmail, Mustafa  * Returns 0 on success or a negative error code.
719047811bSIsmail, Mustafa  */
72f00e6463SLeon Romanovsky int rdma_nl_unicast_wait(struct sk_buff *skb, __u32 pid);
739047811bSIsmail, Mustafa 
749047811bSIsmail, Mustafa /**
7530dc5e63STatyana Nikolova  * Send the supplied skb to a netlink group.
7630dc5e63STatyana Nikolova  * @skb: The netlink skb
7730dc5e63STatyana Nikolova  * @group: Netlink group ID
7830dc5e63STatyana Nikolova  * @flags: allocation flags
7930dc5e63STatyana Nikolova  * Returns 0 on success or a negative error code.
8030dc5e63STatyana Nikolova  */
814d7f693aSLeon Romanovsky int rdma_nl_multicast(struct sk_buff *skb, unsigned int group, gfp_t flags);
8230dc5e63STatyana Nikolova 
83ff61c425SLeon Romanovsky /**
84ff61c425SLeon Romanovsky  * Check if there are any listeners to the netlink group
85ff61c425SLeon Romanovsky  * @group: the netlink group ID
86ff61c425SLeon Romanovsky  * Returns 0 on success or a negative for no listeners.
87ff61c425SLeon Romanovsky  */
88ff61c425SLeon Romanovsky int rdma_nl_chk_listeners(unsigned int group);
89b2cbae2cSRoland Dreier #endif /* _RDMA_NETLINK_H */
90