1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0 3 * 4 * Copyright (c) 2004 Topspin Communications. All rights reserved. 5 * 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: 11 * 12 * Redistribution and use in source and binary forms, with or 13 * without modification, are permitted provided that the following 14 * conditions are met: 15 * 16 * - Redistributions of source code must retain the above 17 * copyright notice, this list of conditions and the following 18 * disclaimer. 19 * 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. 24 * 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 32 * SOFTWARE. 33 * 34 * $FreeBSD$ 35 */ 36 37 #ifndef _CORE_PRIV_H 38 #define _CORE_PRIV_H 39 40 #include <linux/list.h> 41 #include <linux/spinlock.h> 42 43 #include <rdma/ib_verbs.h> 44 45 #include <net/if_vlan_var.h> 46 47 #ifdef CONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS 48 int cma_configfs_init(void); 49 void cma_configfs_exit(void); 50 #else 51 static inline int cma_configfs_init(void) 52 { 53 return 0; 54 } 55 56 static inline void cma_configfs_exit(void) 57 { 58 } 59 #endif 60 struct cma_device; 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, 65 void *cookie); 66 int cma_get_default_gid_type(struct cma_device *cma_dev, 67 unsigned int port); 68 int cma_set_default_gid_type(struct cma_device *cma_dev, 69 unsigned int port, 70 enum ib_gid_type default_gid_type); 71 struct ib_device *cma_get_ib_dev(struct cma_device *cma_dev); 72 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); 77 78 void ib_cache_setup(void); 79 void ib_cache_cleanup(void); 80 81 typedef void (*roce_netdev_callback)(struct ib_device *device, u8 port, 82 struct net_device *idev, void *cookie); 83 84 typedef int (*roce_netdev_filter)(struct ib_device *device, u8 port, 85 struct net_device *idev, void *cookie); 86 87 void ib_enum_roce_netdev(struct ib_device *ib_dev, 88 roce_netdev_filter filter, 89 void *filter_cookie, 90 roce_netdev_callback cb, 91 void *cookie); 92 void ib_enum_all_roce_netdevs(roce_netdev_filter filter, 93 void *filter_cookie, 94 roce_netdev_callback cb, 95 void *cookie); 96 97 enum ib_cache_gid_default_mode { 98 IB_CACHE_GID_DEFAULT_MODE_SET, 99 IB_CACHE_GID_DEFAULT_MODE_DELETE 100 }; 101 102 int ib_cache_gid_parse_type_str(const char *buf); 103 104 const char *ib_cache_gid_type_str(enum ib_gid_type gid_type); 105 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); 110 111 int ib_cache_gid_add(struct ib_device *ib_dev, u8 port, 112 union ib_gid *gid, struct ib_gid_attr *attr); 113 114 int ib_cache_gid_del(struct ib_device *ib_dev, u8 port, 115 union ib_gid *gid, struct ib_gid_attr *attr); 116 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); 120 121 int roce_gid_mgmt_init(void); 122 void roce_gid_mgmt_cleanup(void); 123 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); 126 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); 130 131 static inline bool rdma_is_upper_dev_rcu(struct net_device *dev, 132 struct net_device *upper) 133 { 134 135 /* TODO: add support for LAGG */ 136 upper = VLAN_TRUNKDEV(upper); 137 138 return (dev == upper); 139 } 140 141 int addr_init(void); 142 void addr_cleanup(void); 143 144 int ib_mad_init(void); 145 void ib_mad_cleanup(void); 146 147 int ib_sa_init(void); 148 void ib_sa_cleanup(void); 149 150 #endif /* _CORE_PRIV_H */ 151