2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
4 * Copyright (c) 2004 Topspin Communications. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40 #include <linux/list.h>
41 #include <linux/spinlock.h>
43 #include <rdma/ib_verbs.h>
45 #include <net/if_vlan_var.h>
47 #ifdef CONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS
48 int cma_configfs_init(void);
49 void cma_configfs_exit(void);
51 static inline int cma_configfs_init(void)
56 static inline void cma_configfs_exit(void)
61 void cma_ref_dev(struct cma_device *cma_dev);
62 void cma_deref_dev(struct cma_device *cma_dev);
63 typedef bool (*cma_device_filter)(struct ib_device *, void *);
64 struct cma_device *cma_enum_devices_by_ibdev(cma_device_filter filter,
66 int cma_get_default_gid_type(struct cma_device *cma_dev,
68 int cma_set_default_gid_type(struct cma_device *cma_dev,
70 enum ib_gid_type default_gid_type);
71 struct ib_device *cma_get_ib_dev(struct cma_device *cma_dev);
73 int ib_device_register_sysfs(struct ib_device *device,
74 int (*port_callback)(struct ib_device *,
75 u8, struct kobject *));
76 void ib_device_unregister_sysfs(struct ib_device *device);
78 void ib_cache_setup(void);
79 void ib_cache_cleanup(void);
81 typedef void (*roce_netdev_callback)(struct ib_device *device, u8 port,
82 struct net_device *idev, void *cookie);
84 typedef int (*roce_netdev_filter)(struct ib_device *device, u8 port,
85 struct net_device *idev, void *cookie);
87 void ib_enum_roce_netdev(struct ib_device *ib_dev,
88 roce_netdev_filter filter,
90 roce_netdev_callback cb,
92 void ib_enum_all_roce_netdevs(roce_netdev_filter filter,
94 roce_netdev_callback cb,
97 enum ib_cache_gid_default_mode {
98 IB_CACHE_GID_DEFAULT_MODE_SET,
99 IB_CACHE_GID_DEFAULT_MODE_DELETE
102 int ib_cache_gid_parse_type_str(const char *buf);
104 const char *ib_cache_gid_type_str(enum ib_gid_type gid_type);
106 void ib_cache_gid_set_default_gid(struct ib_device *ib_dev, u8 port,
107 struct net_device *ndev,
108 unsigned long gid_type_mask,
109 enum ib_cache_gid_default_mode mode);
111 int ib_cache_gid_add(struct ib_device *ib_dev, u8 port,
112 union ib_gid *gid, struct ib_gid_attr *attr);
114 int ib_cache_gid_del(struct ib_device *ib_dev, u8 port,
115 union ib_gid *gid, struct ib_gid_attr *attr);
117 int ib_cache_gid_del_all_netdev_gids(struct ib_device *ib_dev, u8 port,
118 struct net_device *ndev);
119 void ib_cache_gid_del_all_by_netdev(struct net_device *ndev);
121 int roce_gid_mgmt_init(void);
122 void roce_gid_mgmt_cleanup(void);
124 int roce_rescan_device(struct ib_device *ib_dev);
125 unsigned long roce_gid_type_mask_support(struct ib_device *ib_dev, u8 port);
127 int ib_cache_setup_one(struct ib_device *device);
128 void ib_cache_cleanup_one(struct ib_device *device);
129 void ib_cache_release_one(struct ib_device *device);
131 static inline bool rdma_is_upper_dev_rcu(struct net_device *dev,
132 struct net_device *upper)
135 /* TODO: add support for LAGG */
136 upper = VLAN_TRUNKDEV(upper);
138 return (dev == upper);
142 void addr_cleanup(void);
144 int ib_mad_init(void);
145 void ib_mad_cleanup(void);
147 int ib_sa_init(void);
148 void ib_sa_cleanup(void);
150 #endif /* _CORE_PRIV_H */