Loading...
1/*
2 * Copyright (c) 2004 Topspin Communications. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32
33#ifndef _CORE_PRIV_H
34#define _CORE_PRIV_H
35
36#include <linux/list.h>
37#include <linux/spinlock.h>
38#include <linux/cgroup_rdma.h>
39#include <net/net_namespace.h>
40#include <net/netns/generic.h>
41
42#include <rdma/ib_verbs.h>
43#include <rdma/opa_addr.h>
44#include <rdma/ib_mad.h>
45#include <rdma/restrack.h>
46#include "mad_priv.h"
47#include "restrack.h"
48
49/* Total number of ports combined across all struct ib_devices's */
50#define RDMA_MAX_PORTS 8192
51
52struct pkey_index_qp_list {
53 struct list_head pkey_index_list;
54 u16 pkey_index;
55 /* Lock to hold while iterating the qp_list. */
56 spinlock_t qp_list_lock;
57 struct list_head qp_list;
58};
59
60/**
61 * struct rdma_dev_net - rdma net namespace metadata for a net
62 * @nl_sock: Pointer to netlink socket
63 * @net: Pointer to owner net namespace
64 * @id: xarray id to identify the net namespace.
65 */
66struct rdma_dev_net {
67 struct sock *nl_sock;
68 possible_net_t net;
69 u32 id;
70};
71
72extern const struct attribute_group ib_dev_attr_group;
73extern bool ib_devices_shared_netns;
74extern unsigned int rdma_dev_net_id;
75
76static inline struct rdma_dev_net *rdma_net_to_dev_net(struct net *net)
77{
78 return net_generic(net, rdma_dev_net_id);
79}
80
81int ib_device_rename(struct ib_device *ibdev, const char *name);
82int ib_device_set_dim(struct ib_device *ibdev, u8 use_dim);
83
84typedef void (*roce_netdev_callback)(struct ib_device *device, u32 port,
85 struct net_device *idev, void *cookie);
86
87typedef bool (*roce_netdev_filter)(struct ib_device *device, u32 port,
88 struct net_device *idev, void *cookie);
89
90struct net_device *ib_device_get_netdev(struct ib_device *ib_dev,
91 u32 port);
92
93void ib_enum_roce_netdev(struct ib_device *ib_dev,
94 roce_netdev_filter filter,
95 void *filter_cookie,
96 roce_netdev_callback cb,
97 void *cookie);
98void ib_enum_all_roce_netdevs(roce_netdev_filter filter,
99 void *filter_cookie,
100 roce_netdev_callback cb,
101 void *cookie);
102
103typedef int (*nldev_callback)(struct ib_device *device,
104 struct sk_buff *skb,
105 struct netlink_callback *cb,
106 unsigned int idx);
107
108int ib_enum_all_devs(nldev_callback nldev_cb, struct sk_buff *skb,
109 struct netlink_callback *cb);
110
111struct ib_client_nl_info {
112 struct sk_buff *nl_msg;
113 struct device *cdev;
114 u32 port;
115 u64 abi;
116};
117int ib_get_client_nl_info(struct ib_device *ibdev, const char *client_name,
118 struct ib_client_nl_info *res);
119
120enum ib_cache_gid_default_mode {
121 IB_CACHE_GID_DEFAULT_MODE_SET,
122 IB_CACHE_GID_DEFAULT_MODE_DELETE
123};
124
125int ib_cache_gid_parse_type_str(const char *buf);
126
127const char *ib_cache_gid_type_str(enum ib_gid_type gid_type);
128
129void ib_cache_gid_set_default_gid(struct ib_device *ib_dev, u32 port,
130 struct net_device *ndev,
131 unsigned long gid_type_mask,
132 enum ib_cache_gid_default_mode mode);
133
134int ib_cache_gid_add(struct ib_device *ib_dev, u32 port,
135 union ib_gid *gid, struct ib_gid_attr *attr);
136
137int ib_cache_gid_del(struct ib_device *ib_dev, u32 port,
138 union ib_gid *gid, struct ib_gid_attr *attr);
139
140int ib_cache_gid_del_all_netdev_gids(struct ib_device *ib_dev, u32 port,
141 struct net_device *ndev);
142
143int roce_gid_mgmt_init(void);
144void roce_gid_mgmt_cleanup(void);
145
146unsigned long roce_gid_type_mask_support(struct ib_device *ib_dev, u32 port);
147
148int ib_cache_setup_one(struct ib_device *device);
149void ib_cache_cleanup_one(struct ib_device *device);
150void ib_cache_release_one(struct ib_device *device);
151void ib_dispatch_event_clients(struct ib_event *event);
152
153#ifdef CONFIG_CGROUP_RDMA
154void ib_device_register_rdmacg(struct ib_device *device);
155void ib_device_unregister_rdmacg(struct ib_device *device);
156
157int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj,
158 struct ib_device *device,
159 enum rdmacg_resource_type resource_index);
160
161void ib_rdmacg_uncharge(struct ib_rdmacg_object *cg_obj,
162 struct ib_device *device,
163 enum rdmacg_resource_type resource_index);
164#else
165static inline void ib_device_register_rdmacg(struct ib_device *device)
166{
167}
168
169static inline void ib_device_unregister_rdmacg(struct ib_device *device)
170{
171}
172
173static inline int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj,
174 struct ib_device *device,
175 enum rdmacg_resource_type resource_index)
176{
177 return 0;
178}
179
180static inline void ib_rdmacg_uncharge(struct ib_rdmacg_object *cg_obj,
181 struct ib_device *device,
182 enum rdmacg_resource_type resource_index)
183{
184}
185#endif
186
187static inline bool rdma_is_upper_dev_rcu(struct net_device *dev,
188 struct net_device *upper)
189{
190 return netdev_has_upper_dev_all_rcu(dev, upper);
191}
192
193int addr_init(void);
194void addr_cleanup(void);
195
196int ib_mad_init(void);
197void ib_mad_cleanup(void);
198
199int ib_sa_init(void);
200void ib_sa_cleanup(void);
201
202void rdma_nl_init(void);
203void rdma_nl_exit(void);
204
205int ib_nl_handle_resolve_resp(struct sk_buff *skb,
206 struct nlmsghdr *nlh,
207 struct netlink_ext_ack *extack);
208int ib_nl_handle_set_timeout(struct sk_buff *skb,
209 struct nlmsghdr *nlh,
210 struct netlink_ext_ack *extack);
211int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
212 struct nlmsghdr *nlh,
213 struct netlink_ext_ack *extack);
214
215void ib_get_cached_subnet_prefix(struct ib_device *device,
216 u32 port_num,
217 u64 *sn_pfx);
218
219#ifdef CONFIG_SECURITY_INFINIBAND
220void ib_security_release_port_pkey_list(struct ib_device *device);
221
222void ib_security_cache_change(struct ib_device *device,
223 u32 port_num,
224 u64 subnet_prefix);
225
226int ib_security_modify_qp(struct ib_qp *qp,
227 struct ib_qp_attr *qp_attr,
228 int qp_attr_mask,
229 struct ib_udata *udata);
230
231int ib_create_qp_security(struct ib_qp *qp, struct ib_device *dev);
232void ib_destroy_qp_security_begin(struct ib_qp_security *sec);
233void ib_destroy_qp_security_abort(struct ib_qp_security *sec);
234void ib_destroy_qp_security_end(struct ib_qp_security *sec);
235int ib_open_shared_qp_security(struct ib_qp *qp, struct ib_device *dev);
236void ib_close_shared_qp_security(struct ib_qp_security *sec);
237int ib_mad_agent_security_setup(struct ib_mad_agent *agent,
238 enum ib_qp_type qp_type);
239void ib_mad_agent_security_cleanup(struct ib_mad_agent *agent);
240int ib_mad_enforce_security(struct ib_mad_agent_private *map, u16 pkey_index);
241void ib_mad_agent_security_change(void);
242#else
243static inline void ib_security_release_port_pkey_list(struct ib_device *device)
244{
245}
246
247static inline void ib_security_cache_change(struct ib_device *device,
248 u32 port_num,
249 u64 subnet_prefix)
250{
251}
252
253static inline int ib_security_modify_qp(struct ib_qp *qp,
254 struct ib_qp_attr *qp_attr,
255 int qp_attr_mask,
256 struct ib_udata *udata)
257{
258 return qp->device->ops.modify_qp(qp->real_qp,
259 qp_attr,
260 qp_attr_mask,
261 udata);
262}
263
264static inline int ib_create_qp_security(struct ib_qp *qp,
265 struct ib_device *dev)
266{
267 return 0;
268}
269
270static inline void ib_destroy_qp_security_begin(struct ib_qp_security *sec)
271{
272}
273
274static inline void ib_destroy_qp_security_abort(struct ib_qp_security *sec)
275{
276}
277
278static inline void ib_destroy_qp_security_end(struct ib_qp_security *sec)
279{
280}
281
282static inline int ib_open_shared_qp_security(struct ib_qp *qp,
283 struct ib_device *dev)
284{
285 return 0;
286}
287
288static inline void ib_close_shared_qp_security(struct ib_qp_security *sec)
289{
290}
291
292static inline int ib_mad_agent_security_setup(struct ib_mad_agent *agent,
293 enum ib_qp_type qp_type)
294{
295 return 0;
296}
297
298static inline void ib_mad_agent_security_cleanup(struct ib_mad_agent *agent)
299{
300}
301
302static inline int ib_mad_enforce_security(struct ib_mad_agent_private *map,
303 u16 pkey_index)
304{
305 return 0;
306}
307
308static inline void ib_mad_agent_security_change(void)
309{
310}
311#endif
312
313struct ib_device *ib_device_get_by_index(const struct net *net, u32 index);
314
315/* RDMA device netlink */
316void nldev_init(void);
317void nldev_exit(void);
318
319struct ib_qp *ib_create_qp_user(struct ib_device *dev, struct ib_pd *pd,
320 struct ib_qp_init_attr *attr,
321 struct ib_udata *udata,
322 struct ib_uqp_object *uobj, const char *caller);
323
324void ib_qp_usecnt_inc(struct ib_qp *qp);
325void ib_qp_usecnt_dec(struct ib_qp *qp);
326
327struct rdma_dev_addr;
328int rdma_resolve_ip_route(struct sockaddr *src_addr,
329 const struct sockaddr *dst_addr,
330 struct rdma_dev_addr *addr);
331
332int rdma_addr_find_l2_eth_by_grh(const union ib_gid *sgid,
333 const union ib_gid *dgid,
334 u8 *dmac, const struct ib_gid_attr *sgid_attr,
335 int *hoplimit);
336void rdma_copy_src_l2_addr(struct rdma_dev_addr *dev_addr,
337 const struct net_device *dev);
338
339struct sa_path_rec;
340int roce_resolve_route_from_path(struct sa_path_rec *rec,
341 const struct ib_gid_attr *attr);
342
343struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr);
344
345void ib_free_port_attrs(struct ib_core_device *coredev);
346int ib_setup_port_attrs(struct ib_core_device *coredev);
347struct rdma_hw_stats *ib_get_hw_stats_port(struct ib_device *ibdev, u32 port_num);
348void ib_device_release_hw_stats(struct hw_stats_device_data *data);
349int ib_setup_device_attrs(struct ib_device *ibdev);
350
351int rdma_compatdev_set(u8 enable);
352
353int ib_port_register_client_groups(struct ib_device *ibdev, u32 port_num,
354 const struct attribute_group **groups);
355void ib_port_unregister_client_groups(struct ib_device *ibdev, u32 port_num,
356 const struct attribute_group **groups);
357
358int ib_device_set_netns_put(struct sk_buff *skb,
359 struct ib_device *dev, u32 ns_fd);
360
361int rdma_nl_net_init(struct rdma_dev_net *rnet);
362void rdma_nl_net_exit(struct rdma_dev_net *rnet);
363
364struct rdma_umap_priv {
365 struct vm_area_struct *vma;
366 struct list_head list;
367 struct rdma_user_mmap_entry *entry;
368};
369
370void rdma_umap_priv_init(struct rdma_umap_priv *priv,
371 struct vm_area_struct *vma,
372 struct rdma_user_mmap_entry *entry);
373
374void ib_cq_pool_cleanup(struct ib_device *dev);
375
376bool rdma_nl_get_privileged_qkey(void);
377#endif /* _CORE_PRIV_H */
1/*
2 * Copyright (c) 2004 Topspin Communications. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32
33#ifndef _CORE_PRIV_H
34#define _CORE_PRIV_H
35
36#include <linux/list.h>
37#include <linux/spinlock.h>
38#include <linux/cgroup_rdma.h>
39
40#include <rdma/ib_verbs.h>
41#include <rdma/opa_addr.h>
42#include <rdma/ib_mad.h>
43#include <rdma/restrack.h>
44#include "mad_priv.h"
45
46/* Total number of ports combined across all struct ib_devices's */
47#define RDMA_MAX_PORTS 1024
48
49struct pkey_index_qp_list {
50 struct list_head pkey_index_list;
51 u16 pkey_index;
52 /* Lock to hold while iterating the qp_list. */
53 spinlock_t qp_list_lock;
54 struct list_head qp_list;
55};
56
57#if IS_ENABLED(CONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS)
58int cma_configfs_init(void);
59void cma_configfs_exit(void);
60#else
61static inline int cma_configfs_init(void)
62{
63 return 0;
64}
65
66static inline void cma_configfs_exit(void)
67{
68}
69#endif
70struct cma_device;
71void cma_ref_dev(struct cma_device *cma_dev);
72void cma_deref_dev(struct cma_device *cma_dev);
73typedef bool (*cma_device_filter)(struct ib_device *, void *);
74struct cma_device *cma_enum_devices_by_ibdev(cma_device_filter filter,
75 void *cookie);
76int cma_get_default_gid_type(struct cma_device *cma_dev,
77 unsigned int port);
78int cma_set_default_gid_type(struct cma_device *cma_dev,
79 unsigned int port,
80 enum ib_gid_type default_gid_type);
81int cma_get_default_roce_tos(struct cma_device *cma_dev, unsigned int port);
82int cma_set_default_roce_tos(struct cma_device *a_dev, unsigned int port,
83 u8 default_roce_tos);
84struct ib_device *cma_get_ib_dev(struct cma_device *cma_dev);
85
86int ib_device_register_sysfs(struct ib_device *device,
87 int (*port_callback)(struct ib_device *,
88 u8, struct kobject *));
89void ib_device_unregister_sysfs(struct ib_device *device);
90
91void ib_cache_setup(void);
92void ib_cache_cleanup(void);
93
94typedef void (*roce_netdev_callback)(struct ib_device *device, u8 port,
95 struct net_device *idev, void *cookie);
96
97typedef int (*roce_netdev_filter)(struct ib_device *device, u8 port,
98 struct net_device *idev, void *cookie);
99
100void ib_enum_roce_netdev(struct ib_device *ib_dev,
101 roce_netdev_filter filter,
102 void *filter_cookie,
103 roce_netdev_callback cb,
104 void *cookie);
105void ib_enum_all_roce_netdevs(roce_netdev_filter filter,
106 void *filter_cookie,
107 roce_netdev_callback cb,
108 void *cookie);
109
110typedef int (*nldev_callback)(struct ib_device *device,
111 struct sk_buff *skb,
112 struct netlink_callback *cb,
113 unsigned int idx);
114
115int ib_enum_all_devs(nldev_callback nldev_cb, struct sk_buff *skb,
116 struct netlink_callback *cb);
117
118enum ib_cache_gid_default_mode {
119 IB_CACHE_GID_DEFAULT_MODE_SET,
120 IB_CACHE_GID_DEFAULT_MODE_DELETE
121};
122
123int ib_cache_gid_parse_type_str(const char *buf);
124
125const char *ib_cache_gid_type_str(enum ib_gid_type gid_type);
126
127void ib_cache_gid_set_default_gid(struct ib_device *ib_dev, u8 port,
128 struct net_device *ndev,
129 unsigned long gid_type_mask,
130 enum ib_cache_gid_default_mode mode);
131
132int ib_cache_gid_add(struct ib_device *ib_dev, u8 port,
133 union ib_gid *gid, struct ib_gid_attr *attr);
134
135int ib_cache_gid_del(struct ib_device *ib_dev, u8 port,
136 union ib_gid *gid, struct ib_gid_attr *attr);
137
138int ib_cache_gid_del_all_netdev_gids(struct ib_device *ib_dev, u8 port,
139 struct net_device *ndev);
140
141int roce_gid_mgmt_init(void);
142void roce_gid_mgmt_cleanup(void);
143
144unsigned long roce_gid_type_mask_support(struct ib_device *ib_dev, u8 port);
145
146int ib_cache_setup_one(struct ib_device *device);
147void ib_cache_cleanup_one(struct ib_device *device);
148void ib_cache_release_one(struct ib_device *device);
149
150#ifdef CONFIG_CGROUP_RDMA
151int ib_device_register_rdmacg(struct ib_device *device);
152void ib_device_unregister_rdmacg(struct ib_device *device);
153
154int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj,
155 struct ib_device *device,
156 enum rdmacg_resource_type resource_index);
157
158void ib_rdmacg_uncharge(struct ib_rdmacg_object *cg_obj,
159 struct ib_device *device,
160 enum rdmacg_resource_type resource_index);
161#else
162static inline int ib_device_register_rdmacg(struct ib_device *device)
163{ return 0; }
164
165static inline void ib_device_unregister_rdmacg(struct ib_device *device)
166{ }
167
168static inline int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj,
169 struct ib_device *device,
170 enum rdmacg_resource_type resource_index)
171{ return 0; }
172
173static inline void ib_rdmacg_uncharge(struct ib_rdmacg_object *cg_obj,
174 struct ib_device *device,
175 enum rdmacg_resource_type resource_index)
176{ }
177#endif
178
179static inline bool rdma_is_upper_dev_rcu(struct net_device *dev,
180 struct net_device *upper)
181{
182 return netdev_has_upper_dev_all_rcu(dev, upper);
183}
184
185int addr_init(void);
186void addr_cleanup(void);
187
188int ib_mad_init(void);
189void ib_mad_cleanup(void);
190
191int ib_sa_init(void);
192void ib_sa_cleanup(void);
193
194int rdma_nl_init(void);
195void rdma_nl_exit(void);
196
197int ib_nl_handle_resolve_resp(struct sk_buff *skb,
198 struct nlmsghdr *nlh,
199 struct netlink_ext_ack *extack);
200int ib_nl_handle_set_timeout(struct sk_buff *skb,
201 struct nlmsghdr *nlh,
202 struct netlink_ext_ack *extack);
203int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
204 struct nlmsghdr *nlh,
205 struct netlink_ext_ack *extack);
206
207int ib_get_cached_subnet_prefix(struct ib_device *device,
208 u8 port_num,
209 u64 *sn_pfx);
210
211#ifdef CONFIG_SECURITY_INFINIBAND
212void ib_security_destroy_port_pkey_list(struct ib_device *device);
213
214void ib_security_cache_change(struct ib_device *device,
215 u8 port_num,
216 u64 subnet_prefix);
217
218int ib_security_modify_qp(struct ib_qp *qp,
219 struct ib_qp_attr *qp_attr,
220 int qp_attr_mask,
221 struct ib_udata *udata);
222
223int ib_create_qp_security(struct ib_qp *qp, struct ib_device *dev);
224void ib_destroy_qp_security_begin(struct ib_qp_security *sec);
225void ib_destroy_qp_security_abort(struct ib_qp_security *sec);
226void ib_destroy_qp_security_end(struct ib_qp_security *sec);
227int ib_open_shared_qp_security(struct ib_qp *qp, struct ib_device *dev);
228void ib_close_shared_qp_security(struct ib_qp_security *sec);
229int ib_mad_agent_security_setup(struct ib_mad_agent *agent,
230 enum ib_qp_type qp_type);
231void ib_mad_agent_security_cleanup(struct ib_mad_agent *agent);
232int ib_mad_enforce_security(struct ib_mad_agent_private *map, u16 pkey_index);
233#else
234static inline void ib_security_destroy_port_pkey_list(struct ib_device *device)
235{
236}
237
238static inline void ib_security_cache_change(struct ib_device *device,
239 u8 port_num,
240 u64 subnet_prefix)
241{
242}
243
244static inline int ib_security_modify_qp(struct ib_qp *qp,
245 struct ib_qp_attr *qp_attr,
246 int qp_attr_mask,
247 struct ib_udata *udata)
248{
249 return qp->device->modify_qp(qp->real_qp,
250 qp_attr,
251 qp_attr_mask,
252 udata);
253}
254
255static inline int ib_create_qp_security(struct ib_qp *qp,
256 struct ib_device *dev)
257{
258 return 0;
259}
260
261static inline void ib_destroy_qp_security_begin(struct ib_qp_security *sec)
262{
263}
264
265static inline void ib_destroy_qp_security_abort(struct ib_qp_security *sec)
266{
267}
268
269static inline void ib_destroy_qp_security_end(struct ib_qp_security *sec)
270{
271}
272
273static inline int ib_open_shared_qp_security(struct ib_qp *qp,
274 struct ib_device *dev)
275{
276 return 0;
277}
278
279static inline void ib_close_shared_qp_security(struct ib_qp_security *sec)
280{
281}
282
283static inline int ib_mad_agent_security_setup(struct ib_mad_agent *agent,
284 enum ib_qp_type qp_type)
285{
286 return 0;
287}
288
289static inline void ib_mad_agent_security_cleanup(struct ib_mad_agent *agent)
290{
291}
292
293static inline int ib_mad_enforce_security(struct ib_mad_agent_private *map,
294 u16 pkey_index)
295{
296 return 0;
297}
298#endif
299
300struct ib_device *ib_device_get_by_index(u32 ifindex);
301/* RDMA device netlink */
302void nldev_init(void);
303void nldev_exit(void);
304
305static inline struct ib_qp *_ib_create_qp(struct ib_device *dev,
306 struct ib_pd *pd,
307 struct ib_qp_init_attr *attr,
308 struct ib_udata *udata,
309 struct ib_uobject *uobj)
310{
311 struct ib_qp *qp;
312
313 if (!dev->create_qp)
314 return ERR_PTR(-EOPNOTSUPP);
315
316 qp = dev->create_qp(pd, attr, udata);
317 if (IS_ERR(qp))
318 return qp;
319
320 qp->device = dev;
321 qp->pd = pd;
322 qp->uobject = uobj;
323 /*
324 * We don't track XRC QPs for now, because they don't have PD
325 * and more importantly they are created internaly by driver,
326 * see mlx5 create_dev_resources() as an example.
327 */
328 if (attr->qp_type < IB_QPT_XRC_INI) {
329 qp->res.type = RDMA_RESTRACK_QP;
330 rdma_restrack_add(&qp->res);
331 } else
332 qp->res.valid = false;
333
334 return qp;
335}
336
337struct rdma_dev_addr;
338int rdma_resolve_ip_route(struct sockaddr *src_addr,
339 const struct sockaddr *dst_addr,
340 struct rdma_dev_addr *addr);
341
342int rdma_addr_find_l2_eth_by_grh(const union ib_gid *sgid,
343 const union ib_gid *dgid,
344 u8 *dmac, const struct net_device *ndev,
345 int *hoplimit);
346
347#endif /* _CORE_PRIV_H */