Loading...
1#ifndef _RDMA_NETLINK_H
2#define _RDMA_NETLINK_H
3
4#include <linux/types.h>
5
6enum {
7 RDMA_NL_RDMA_CM = 1
8};
9
10#define RDMA_NL_GET_CLIENT(type) ((type & (((1 << 6) - 1) << 10)) >> 10)
11#define RDMA_NL_GET_OP(type) (type & ((1 << 10) - 1))
12#define RDMA_NL_GET_TYPE(client, op) ((client << 10) + op)
13
14enum {
15 RDMA_NL_RDMA_CM_ID_STATS = 0,
16 RDMA_NL_RDMA_CM_NUM_OPS
17};
18
19enum {
20 RDMA_NL_RDMA_CM_ATTR_SRC_ADDR = 1,
21 RDMA_NL_RDMA_CM_ATTR_DST_ADDR,
22 RDMA_NL_RDMA_CM_NUM_ATTR,
23};
24
25struct rdma_cm_id_stats {
26 __u32 qp_num;
27 __u32 bound_dev_if;
28 __u32 port_space;
29 __s32 pid;
30 __u8 cm_state;
31 __u8 node_type;
32 __u8 port_num;
33 __u8 qp_type;
34};
35
36#ifdef __KERNEL__
37
38#include <linux/netlink.h>
39
40struct ibnl_client_cbs {
41 int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
42};
43
44int ibnl_init(void);
45void ibnl_cleanup(void);
46
47/**
48 * Add a a client to the list of IB netlink exporters.
49 * @index: Index of the added client
50 * @nops: Number of supported ops by the added client.
51 * @cb_table: A table for op->callback
52 *
53 * Returns 0 on success or a negative error code.
54 */
55int ibnl_add_client(int index, int nops,
56 const struct ibnl_client_cbs cb_table[]);
57
58/**
59 * Remove a client from IB netlink.
60 * @index: Index of the removed IB client.
61 *
62 * Returns 0 on success or a negative error code.
63 */
64int ibnl_remove_client(int index);
65
66/**
67 * Put a new message in a supplied skb.
68 * @skb: The netlink skb.
69 * @nlh: Pointer to put the header of the new netlink message.
70 * @seq: The message sequence number.
71 * @len: The requested message length to allocate.
72 * @client: Calling IB netlink client.
73 * @op: message content op.
74 * Returns the allocated buffer on success and NULL on failure.
75 */
76void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
77 int len, int client, int op);
78/**
79 * Put a new attribute in a supplied skb.
80 * @skb: The netlink skb.
81 * @nlh: Header of the netlink message to append the attribute to.
82 * @len: The length of the attribute data.
83 * @data: The attribute data to put.
84 * @type: The attribute type.
85 * Returns the 0 and a negative error code on failure.
86 */
87int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
88 int len, void *data, int type);
89
90#endif /* __KERNEL__ */
91
92#endif /* _RDMA_NETLINK_H */
1#ifndef _RDMA_NETLINK_H
2#define _RDMA_NETLINK_H
3
4
5#include <linux/netlink.h>
6#include <uapi/rdma/rdma_netlink.h>
7
8struct ibnl_client_cbs {
9 int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
10 struct module *module;
11};
12
13int ibnl_init(void);
14void ibnl_cleanup(void);
15
16/**
17 * Add a a client to the list of IB netlink exporters.
18 * @index: Index of the added client
19 * @nops: Number of supported ops by the added client.
20 * @cb_table: A table for op->callback
21 *
22 * Returns 0 on success or a negative error code.
23 */
24int ibnl_add_client(int index, int nops,
25 const struct ibnl_client_cbs cb_table[]);
26
27/**
28 * Remove a client from IB netlink.
29 * @index: Index of the removed IB client.
30 *
31 * Returns 0 on success or a negative error code.
32 */
33int ibnl_remove_client(int index);
34
35/**
36 * Put a new message in a supplied skb.
37 * @skb: The netlink skb.
38 * @nlh: Pointer to put the header of the new netlink message.
39 * @seq: The message sequence number.
40 * @len: The requested message length to allocate.
41 * @client: Calling IB netlink client.
42 * @op: message content op.
43 * Returns the allocated buffer on success and NULL on failure.
44 */
45void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
46 int len, int client, int op, int flags);
47/**
48 * Put a new attribute in a supplied skb.
49 * @skb: The netlink skb.
50 * @nlh: Header of the netlink message to append the attribute to.
51 * @len: The length of the attribute data.
52 * @data: The attribute data to put.
53 * @type: The attribute type.
54 * Returns the 0 and a negative error code on failure.
55 */
56int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
57 int len, void *data, int type);
58
59/**
60 * Send the supplied skb to a specific userspace PID.
61 * @skb: The netlink skb
62 * @nlh: Header of the netlink message to send
63 * @pid: Userspace netlink process ID
64 * Returns 0 on success or a negative error code.
65 */
66int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
67 __u32 pid);
68
69/**
70 * Send the supplied skb to a netlink group.
71 * @skb: The netlink skb
72 * @nlh: Header of the netlink message to send
73 * @group: Netlink group ID
74 * @flags: allocation flags
75 * Returns 0 on success or a negative error code.
76 */
77int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh,
78 unsigned int group, gfp_t flags);
79
80/**
81 * Check if there are any listeners to the netlink group
82 * @group: the netlink group ID
83 * Returns 0 on success or a negative for no listeners.
84 */
85int ibnl_chk_listeners(unsigned int group);
86
87#endif /* _RDMA_NETLINK_H */