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 48int cma_configfs_init(void); 49void cma_configfs_exit(void); 50#else 51static inline int cma_configfs_init(void) 52{ 53 return 0; 54} 55 56static inline void cma_configfs_exit(void) 57{ 58} 59#endif 60struct cma_device; 61void cma_ref_dev(struct cma_device *cma_dev); 62void cma_deref_dev(struct cma_device *cma_dev); 63typedef bool (*cma_device_filter)(struct ib_device *, void *); 64struct cma_device *cma_enum_devices_by_ibdev(cma_device_filter filter, 65 void *cookie); 66int cma_get_default_gid_type(struct cma_device *cma_dev, 67 unsigned int port); 68int cma_set_default_gid_type(struct cma_device *cma_dev, 69 unsigned int port, 70 enum ib_gid_type default_gid_type); 71struct ib_device *cma_get_ib_dev(struct cma_device *cma_dev); 72 73int ib_device_register_sysfs(struct ib_device *device, 74 int (*port_callback)(struct ib_device *, 75 u8, struct kobject *)); 76void ib_device_unregister_sysfs(struct ib_device *device); 77 78void ib_cache_setup(void); 79void ib_cache_cleanup(void); 80 81typedef void (*roce_netdev_callback)(struct ib_device *device, u8 port, 82 struct net_device *idev, void *cookie); 83 84typedef int (*roce_netdev_filter)(struct ib_device *device, u8 port, 85 struct net_device *idev, void *cookie); 86 87void 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); 92void ib_enum_all_roce_netdevs(roce_netdev_filter filter, 93 void *filter_cookie, 94 roce_netdev_callback cb, 95 void *cookie); 96 97enum ib_cache_gid_default_mode { 98 IB_CACHE_GID_DEFAULT_MODE_SET, 99 IB_CACHE_GID_DEFAULT_MODE_DELETE 100}; 101 102int ib_cache_gid_parse_type_str(const char *buf); 103 104const char *ib_cache_gid_type_str(enum ib_gid_type gid_type); 105 106void 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 111int ib_cache_gid_add(struct ib_device *ib_dev, u8 port, 112 union ib_gid *gid, struct ib_gid_attr *attr); 113 114int ib_cache_gid_del(struct ib_device *ib_dev, u8 port, 115 union ib_gid *gid, struct ib_gid_attr *attr); 116 117int ib_cache_gid_del_all_netdev_gids(struct ib_device *ib_dev, u8 port, 118 struct net_device *ndev); 119void ib_cache_gid_del_all_by_netdev(struct net_device *ndev); 120 121int roce_gid_mgmt_init(void); 122void roce_gid_mgmt_cleanup(void); 123 124int roce_rescan_device(struct ib_device *ib_dev); 125unsigned long roce_gid_type_mask_support(struct ib_device *ib_dev, u8 port); 126 127int ib_cache_setup_one(struct ib_device *device); 128void ib_cache_cleanup_one(struct ib_device *device); 129void ib_cache_release_one(struct ib_device *device); 130 131int addr_init(void); 132void addr_cleanup(void); 133 134int ib_mad_init(void); 135void ib_mad_cleanup(void); 136 137int ib_sa_init(void); 138void ib_sa_cleanup(void); 139 140#endif /* _CORE_PRIV_H */ 141