kernel_optimize_test/include/rdma/rdma_netlink.h
Leon Romanovsky c9901724a2 RDMA/netlink: Remove netlink clients infrastructure
RDMA netlink has a complicated infrastructure for dynamically
registering and de-registering netlink clients to the NETLINK_RDMA
group. The complicated portion of this code is not widely used because
2 of the 3 current clients are statically compiled together with
netlink.c. The infrastructure, therefore, is deemed overkill.

Refactor the code to eliminate the dynamically added clients. Now all
clients are pre-registered in a client array at compile time, and at run
time they merely check-in with the infrastructure to pass their callback
table for inclusion in the pre-sized client array.

This also allows for future cleanups and removal of unneeded code in the
iwcm* netlink handler.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Chien Tin Tung <chien.tin.tung@intel.com>
2017-08-10 13:13:06 +03:00

83 lines
2.4 KiB
C

#ifndef _RDMA_NETLINK_H
#define _RDMA_NETLINK_H
#include <linux/netlink.h>
#include <uapi/rdma/rdma_netlink.h>
struct ibnl_client_cbs {
int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
struct module *module;
};
/**
* Register client in RDMA netlink.
* @index: Index of the added client
* @cb_table: A table for op->callback
*/
void rdma_nl_register(unsigned int index,
const struct ibnl_client_cbs cb_table[]);
/**
* Remove a client from IB netlink.
* @index: Index of the removed IB client.
*/
void rdma_nl_unregister(unsigned int index);
/**
* 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,
int len, int client, int op, int flags);
/**
* 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);
/**
* Send the supplied skb to a specific userspace PID.
* @skb: The netlink skb
* @nlh: Header of the netlink message to send
* @pid: Userspace netlink process ID
* Returns 0 on success or a negative error code.
*/
int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
__u32 pid);
/**
* Send, with wait/1 retry, the supplied skb to a specific userspace PID.
* @skb: The netlink skb
* @nlh: Header of the netlink message to send
* @pid: Userspace netlink process ID
* Returns 0 on success or a negative error code.
*/
int ibnl_unicast_wait(struct sk_buff *skb, struct nlmsghdr *nlh,
__u32 pid);
/**
* Send the supplied skb to a netlink group.
* @skb: The netlink skb
* @nlh: Header of the netlink message to send
* @group: Netlink group ID
* @flags: allocation flags
* Returns 0 on success or a negative error code.
*/
int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh,
unsigned int group, gfp_t flags);
#endif /* _RDMA_NETLINK_H */