2011-05-21 02:46:11 +08:00
|
|
|
#ifndef _RDMA_NETLINK_H
|
|
|
|
#define _RDMA_NETLINK_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <linux/netlink.h>
|
2012-11-21 23:47:40 +08:00
|
|
|
#include <uapi/rdma/rdma_netlink.h>
|
2011-05-21 02:46:11 +08:00
|
|
|
|
2017-06-19 23:23:45 +08:00
|
|
|
struct rdma_nl_cbs {
|
2017-06-15 17:46:33 +08:00
|
|
|
int (*doit)(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|
|
|
struct netlink_ext_ack *extack);
|
2011-05-21 02:46:11 +08:00
|
|
|
int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
|
2017-06-12 21:00:19 +08:00
|
|
|
u8 flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum rdma_nl_flags {
|
|
|
|
/* Require CAP_NET_ADMIN */
|
|
|
|
RDMA_NL_ADMIN_PERM = 1 << 0,
|
2011-05-21 02:46:11 +08:00
|
|
|
};
|
|
|
|
|
2017-08-15 04:57:39 +08:00
|
|
|
/* Define this module as providing netlink services for NETLINK_RDMA, with
|
|
|
|
* index _index. Since the client indexes were setup in a uapi header as an
|
|
|
|
* enum and we do no want to change that, the user must supply the expanded
|
|
|
|
* constant as well and the compiler checks they are the same.
|
|
|
|
*/
|
|
|
|
#define MODULE_ALIAS_RDMA_NETLINK(_index, _val) \
|
|
|
|
static inline void __chk_##_index(void) \
|
|
|
|
{ \
|
|
|
|
BUILD_BUG_ON(_index != _val); \
|
|
|
|
} \
|
|
|
|
MODULE_ALIAS("rdma-netlink-subsys-" __stringify(_val))
|
|
|
|
|
2011-05-21 02:46:11 +08:00
|
|
|
/**
|
2017-06-05 15:20:11 +08:00
|
|
|
* Register client in RDMA netlink.
|
2011-05-21 02:46:11 +08:00
|
|
|
* @index: Index of the added client
|
|
|
|
* @cb_table: A table for op->callback
|
|
|
|
*/
|
2017-06-05 15:20:11 +08:00
|
|
|
void rdma_nl_register(unsigned int index,
|
2017-06-19 23:23:45 +08:00
|
|
|
const struct rdma_nl_cbs cb_table[]);
|
2011-05-21 02:46:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a client from IB netlink.
|
|
|
|
* @index: Index of the removed IB client.
|
|
|
|
*/
|
2017-06-05 15:20:11 +08:00
|
|
|
void rdma_nl_unregister(unsigned int index);
|
2011-05-21 02:46:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Put a new message in a supplied skb.
|
|
|
|
* @skb: The netlink skb.
|
|
|
|
* @nlh: Pointer to put the header of the new netlink message.
|
|
|
|
* @seq: The message sequence number.
|
|
|
|
* @len: The requested message length to allocate.
|
|
|
|
* @client: Calling IB netlink client.
|
|
|
|
* @op: message content op.
|
|
|
|
* Returns the allocated buffer on success and NULL on failure.
|
|
|
|
*/
|
|
|
|
void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
|
2014-03-27 06:07:35 +08:00
|
|
|
int len, int client, int op, int flags);
|
2011-05-21 02:46:11 +08:00
|
|
|
/**
|
|
|
|
* Put a new attribute in a supplied skb.
|
|
|
|
* @skb: The netlink skb.
|
|
|
|
* @nlh: Header of the netlink message to append the attribute to.
|
|
|
|
* @len: The length of the attribute data.
|
|
|
|
* @data: The attribute data to put.
|
|
|
|
* @type: The attribute type.
|
|
|
|
* Returns the 0 and a negative error code on failure.
|
|
|
|
*/
|
|
|
|
int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|
|
|
int len, void *data, int type);
|
|
|
|
|
2014-03-27 06:07:35 +08:00
|
|
|
/**
|
|
|
|
* Send the supplied skb to a specific userspace PID.
|
|
|
|
* @skb: The netlink skb
|
|
|
|
* @pid: Userspace netlink process ID
|
|
|
|
* Returns 0 on success or a negative error code.
|
|
|
|
*/
|
2017-06-18 20:35:20 +08:00
|
|
|
int rdma_nl_unicast(struct sk_buff *skb, u32 pid);
|
2014-03-27 06:07:35 +08:00
|
|
|
|
2017-06-28 22:02:45 +08:00
|
|
|
/**
|
|
|
|
* Send, with wait/1 retry, the supplied skb to a specific userspace PID.
|
|
|
|
* @skb: The netlink skb
|
|
|
|
* @pid: Userspace netlink process ID
|
|
|
|
* Returns 0 on success or a negative error code.
|
|
|
|
*/
|
2017-06-18 20:35:20 +08:00
|
|
|
int rdma_nl_unicast_wait(struct sk_buff *skb, __u32 pid);
|
2017-06-28 22:02:45 +08:00
|
|
|
|
2014-03-27 06:07:35 +08:00
|
|
|
/**
|
|
|
|
* Send the supplied skb to a netlink group.
|
|
|
|
* @skb: The netlink skb
|
|
|
|
* @group: Netlink group ID
|
|
|
|
* @flags: allocation flags
|
|
|
|
* Returns 0 on success or a negative error code.
|
|
|
|
*/
|
2017-06-18 20:44:32 +08:00
|
|
|
int rdma_nl_multicast(struct sk_buff *skb, unsigned int group, gfp_t flags);
|
2014-03-27 06:07:35 +08:00
|
|
|
|
2017-06-18 20:51:16 +08:00
|
|
|
/**
|
|
|
|
* Check if there are any listeners to the netlink group
|
|
|
|
* @group: the netlink group ID
|
|
|
|
* Returns 0 on success or a negative for no listeners.
|
|
|
|
*/
|
|
|
|
int rdma_nl_chk_listeners(unsigned int group);
|
2011-05-21 02:46:11 +08:00
|
|
|
#endif /* _RDMA_NETLINK_H */
|