diff options
author | Roland Dreier <roland@purestorage.com> | 2011-05-20 14:46:11 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2011-05-20 14:46:11 -0400 |
commit | b2cbae2c248776d81cc265ff7d48405b6a4cc463 (patch) | |
tree | fbd4f4e0812fbcc991670c81967e90bfdd9f80c0 /include/rdma | |
parent | fd75c789abf7948e16fe50917a6acb809927719a (diff) |
RDMA: Add netlink infrastructure
Add basic RDMA netlink infrastructure that allows for registration of
RDMA clients for which data is to be exported and supplies message
construction callbacks.
Signed-off-by: Nir Muchtar <nirm@voltaire.com>
[ Reorganize a few things, add CONFIG_NET dependency. - Roland ]
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'include/rdma')
-rw-r--r-- | include/rdma/rdma_netlink.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h new file mode 100644 index 000000000000..c983a193cecf --- /dev/null +++ b/include/rdma/rdma_netlink.h | |||
@@ -0,0 +1,64 @@ | |||
1 | #ifndef _RDMA_NETLINK_H | ||
2 | #define _RDMA_NETLINK_H | ||
3 | |||
4 | #define RDMA_NL_GET_CLIENT(type) ((type & (((1 << 6) - 1) << 10)) >> 10) | ||
5 | #define RDMA_NL_GET_OP(type) (type & ((1 << 10) - 1)) | ||
6 | #define RDMA_NL_GET_TYPE(client, op) ((client << 10) + op) | ||
7 | |||
8 | #ifdef __KERNEL__ | ||
9 | |||
10 | #include <linux/netlink.h> | ||
11 | |||
12 | struct ibnl_client_cbs { | ||
13 | int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb); | ||
14 | }; | ||
15 | |||
16 | int ibnl_init(void); | ||
17 | void ibnl_cleanup(void); | ||
18 | |||
19 | /** | ||
20 | * Add a a client to the list of IB netlink exporters. | ||
21 | * @index: Index of the added client | ||
22 | * @nops: Number of supported ops by the added client. | ||
23 | * @cb_table: A table for op->callback | ||
24 | * | ||
25 | * Returns 0 on success or a negative error code. | ||
26 | */ | ||
27 | int ibnl_add_client(int index, int nops, | ||
28 | const struct ibnl_client_cbs cb_table[]); | ||
29 | |||
30 | /** | ||
31 | * Remove a client from IB netlink. | ||
32 | * @index: Index of the removed IB client. | ||
33 | * | ||
34 | * Returns 0 on success or a negative error code. | ||
35 | */ | ||
36 | int ibnl_remove_client(int index); | ||
37 | |||
38 | /** | ||
39 | * Put a new message in a supplied skb. | ||
40 | * @skb: The netlink skb. | ||
41 | * @nlh: Pointer to put the header of the new netlink message. | ||
42 | * @seq: The message sequence number. | ||
43 | * @len: The requested message length to allocate. | ||
44 | * @client: Calling IB netlink client. | ||
45 | * @op: message content op. | ||
46 | * Returns the allocated buffer on success and NULL on failure. | ||
47 | */ | ||
48 | void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq, | ||
49 | int len, int client, int op); | ||
50 | /** | ||
51 | * Put a new attribute in a supplied skb. | ||
52 | * @skb: The netlink skb. | ||
53 | * @nlh: Header of the netlink message to append the attribute to. | ||
54 | * @len: The length of the attribute data. | ||
55 | * @data: The attribute data to put. | ||
56 | * @type: The attribute type. | ||
57 | * Returns the 0 and a negative error code on failure. | ||
58 | */ | ||
59 | int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh, | ||
60 | int len, void *data, int type); | ||
61 | |||
62 | #endif /* __KERNEL__ */ | ||
63 | |||
64 | #endif /* _RDMA_NETLINK_H */ | ||