Linux Audio

Check our new training course

Loading...
v3.1
 
 
 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 */
v6.13.7
  1/* SPDX-License-Identifier: GPL-2.0 */
  2
  3#ifndef _RDMA_NETLINK_H
  4#define _RDMA_NETLINK_H
  5
  6#include <linux/netlink.h>
  7#include <uapi/rdma/rdma_netlink.h>
 
 
 
  8
  9struct ib_device;
 
 
 10
 11enum {
 12	RDMA_NLDEV_ATTR_EMPTY_STRING = 1,
 13	RDMA_NLDEV_ATTR_ENTRY_STRLEN = 16,
 14	RDMA_NLDEV_ATTR_CHARDEV_TYPE_SIZE = 32,
 15};
 16
 17struct rdma_nl_cbs {
 18	int (*doit)(struct sk_buff *skb, struct nlmsghdr *nlh,
 19		    struct netlink_ext_ack *extack);
 20	int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
 21	u8 flags;
 22};
 23
 24enum rdma_nl_flags {
 25	/* Require CAP_NET_ADMIN */
 26	RDMA_NL_ADMIN_PERM	= 1 << 0,
 
 
 
 
 
 
 27};
 28
 29/* Define this module as providing netlink services for NETLINK_RDMA, with
 30 * index _index.  Since the client indexes were setup in a uapi header as an
 31 * enum and we do no want to change that, the user must supply the expanded
 32 * constant as well and the compiler checks they are the same.
 33 */
 34#define MODULE_ALIAS_RDMA_NETLINK(_index, _val)                                \
 35	static inline void __maybe_unused __chk_##_index(void)                 \
 36	{                                                                      \
 37		BUILD_BUG_ON(_index != _val);                                  \
 38	}                                                                      \
 39	MODULE_ALIAS("rdma-netlink-subsys-" __stringify(_val))
 40
 41/**
 42 * Register client in RDMA netlink.
 43 * @index: Index of the added client
 
 44 * @cb_table: A table for op->callback
 
 
 45 */
 46void rdma_nl_register(unsigned int index,
 47		      const struct rdma_nl_cbs cb_table[]);
 48
 49/**
 50 * Remove a client from IB netlink.
 51 * @index: Index of the removed IB client.
 
 
 52 */
 53void rdma_nl_unregister(unsigned int index);
 54
 55/**
 56 * Put a new message in a supplied skb.
 57 * @skb: The netlink skb.
 58 * @nlh: Pointer to put the header of the new netlink message.
 59 * @seq: The message sequence number.
 60 * @len: The requested message length to allocate.
 61 * @client: Calling IB netlink client.
 62 * @op: message content op.
 63 * Returns the allocated buffer on success and NULL on failure.
 64 */
 65void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
 66		   int len, int client, int op, int flags);
 67/**
 68 * Put a new attribute in a supplied skb.
 69 * @skb: The netlink skb.
 70 * @nlh: Header of the netlink message to append the attribute to.
 71 * @len: The length of the attribute data.
 72 * @data: The attribute data to put.
 73 * @type: The attribute type.
 74 * Returns the 0 and a negative error code on failure.
 75 */
 76int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
 77		  int len, void *data, int type);
 78
 79/**
 80 * Send the supplied skb to a specific userspace PID.
 81 * @net: Net namespace in which to send the skb
 82 * @skb: The netlink skb
 83 * @pid: Userspace netlink process ID
 84 * Returns 0 on success or a negative error code.
 85 */
 86int rdma_nl_unicast(struct net *net, struct sk_buff *skb, u32 pid);
 87
 88/**
 89 * Send, with wait/1 retry, the supplied skb to a specific userspace PID.
 90 * @net: Net namespace in which to send the skb
 91 * @skb: The netlink skb
 92 * @pid: Userspace netlink process ID
 93 * Returns 0 on success or a negative error code.
 94 */
 95int rdma_nl_unicast_wait(struct net *net, struct sk_buff *skb, __u32 pid);
 96
 97/**
 98 * Send the supplied skb to a netlink group.
 99 * @net: Net namespace in which to send the skb
100 * @skb: The netlink skb
101 * @group: Netlink group ID
102 * @flags: allocation flags
103 * Returns 0 on success or a negative error code.
104 */
105int rdma_nl_multicast(struct net *net, struct sk_buff *skb,
106		      unsigned int group, gfp_t flags);
107
108/**
109 * Check if there are any listeners to the netlink group
110 * @group: the netlink group ID
111 * Returns true on success or false if no listeners.
112 */
113bool rdma_nl_chk_listeners(unsigned int group);
114
115/**
116 * Prepare and send an event message
117 * @ib: the IB device which triggered the event
118 * @port_num: the port number which triggered the event - 0 if unused
119 * @type: the event type
120 * Returns 0 on success or a negative error code
121 */
122int rdma_nl_notify_event(struct ib_device *ib, u32 port_num,
123			 enum rdma_nl_notify_event_type type);
124
125struct rdma_link_ops {
126	struct list_head list;
127	const char *type;
128	int (*newlink)(const char *ibdev_name, struct net_device *ndev);
129};
130
131void rdma_link_register(struct rdma_link_ops *ops);
132void rdma_link_unregister(struct rdma_link_ops *ops);
133
134#define MODULE_ALIAS_RDMA_LINK(type) MODULE_ALIAS("rdma-link-" type)
135#define MODULE_ALIAS_RDMA_CLIENT(type) MODULE_ALIAS("rdma-client-" type)
136
137#endif /* _RDMA_NETLINK_H */