1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Copyright (c) 2004 Topspin Communications. All rights reserved. 4*4882a593Smuzhiyun * Copyright (c) 2005 Intel Corporation. All rights reserved. 5*4882a593Smuzhiyun * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun #ifndef _IB_CACHE_H 9*4882a593Smuzhiyun #define _IB_CACHE_H 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun #include <rdma/ib_verbs.h> 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun int rdma_query_gid(struct ib_device *device, u8 port_num, int index, 14*4882a593Smuzhiyun union ib_gid *gid); 15*4882a593Smuzhiyun void *rdma_read_gid_hw_context(const struct ib_gid_attr *attr); 16*4882a593Smuzhiyun const struct ib_gid_attr *rdma_find_gid(struct ib_device *device, 17*4882a593Smuzhiyun const union ib_gid *gid, 18*4882a593Smuzhiyun enum ib_gid_type gid_type, 19*4882a593Smuzhiyun struct net_device *ndev); 20*4882a593Smuzhiyun const struct ib_gid_attr *rdma_find_gid_by_port(struct ib_device *ib_dev, 21*4882a593Smuzhiyun const union ib_gid *gid, 22*4882a593Smuzhiyun enum ib_gid_type gid_type, 23*4882a593Smuzhiyun u8 port, 24*4882a593Smuzhiyun struct net_device *ndev); 25*4882a593Smuzhiyun const struct ib_gid_attr *rdma_find_gid_by_filter( 26*4882a593Smuzhiyun struct ib_device *device, const union ib_gid *gid, u8 port_num, 27*4882a593Smuzhiyun bool (*filter)(const union ib_gid *gid, const struct ib_gid_attr *, 28*4882a593Smuzhiyun void *), 29*4882a593Smuzhiyun void *context); 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun int rdma_read_gid_l2_fields(const struct ib_gid_attr *attr, 32*4882a593Smuzhiyun u16 *vlan_id, u8 *smac); 33*4882a593Smuzhiyun struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr); 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun /** 36*4882a593Smuzhiyun * ib_get_cached_pkey - Returns a cached PKey table entry 37*4882a593Smuzhiyun * @device: The device to query. 38*4882a593Smuzhiyun * @port_num: The port number of the device to query. 39*4882a593Smuzhiyun * @index: The index into the cached PKey table to query. 40*4882a593Smuzhiyun * @pkey: The PKey value found at the specified index. 41*4882a593Smuzhiyun * 42*4882a593Smuzhiyun * ib_get_cached_pkey() fetches the specified PKey table entry stored in 43*4882a593Smuzhiyun * the local software cache. 44*4882a593Smuzhiyun */ 45*4882a593Smuzhiyun int ib_get_cached_pkey(struct ib_device *device_handle, 46*4882a593Smuzhiyun u8 port_num, 47*4882a593Smuzhiyun int index, 48*4882a593Smuzhiyun u16 *pkey); 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun /** 51*4882a593Smuzhiyun * ib_find_cached_pkey - Returns the PKey table index where a specified 52*4882a593Smuzhiyun * PKey value occurs. 53*4882a593Smuzhiyun * @device: The device to query. 54*4882a593Smuzhiyun * @port_num: The port number of the device to search for the PKey. 55*4882a593Smuzhiyun * @pkey: The PKey value to search for. 56*4882a593Smuzhiyun * @index: The index into the cached PKey table where the PKey was found. 57*4882a593Smuzhiyun * 58*4882a593Smuzhiyun * ib_find_cached_pkey() searches the specified PKey table in 59*4882a593Smuzhiyun * the local software cache. 60*4882a593Smuzhiyun */ 61*4882a593Smuzhiyun int ib_find_cached_pkey(struct ib_device *device, 62*4882a593Smuzhiyun u8 port_num, 63*4882a593Smuzhiyun u16 pkey, 64*4882a593Smuzhiyun u16 *index); 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun /** 67*4882a593Smuzhiyun * ib_find_exact_cached_pkey - Returns the PKey table index where a specified 68*4882a593Smuzhiyun * PKey value occurs. Comparison uses the FULL 16 bits (incl membership bit) 69*4882a593Smuzhiyun * @device: The device to query. 70*4882a593Smuzhiyun * @port_num: The port number of the device to search for the PKey. 71*4882a593Smuzhiyun * @pkey: The PKey value to search for. 72*4882a593Smuzhiyun * @index: The index into the cached PKey table where the PKey was found. 73*4882a593Smuzhiyun * 74*4882a593Smuzhiyun * ib_find_exact_cached_pkey() searches the specified PKey table in 75*4882a593Smuzhiyun * the local software cache. 76*4882a593Smuzhiyun */ 77*4882a593Smuzhiyun int ib_find_exact_cached_pkey(struct ib_device *device, 78*4882a593Smuzhiyun u8 port_num, 79*4882a593Smuzhiyun u16 pkey, 80*4882a593Smuzhiyun u16 *index); 81*4882a593Smuzhiyun 82*4882a593Smuzhiyun /** 83*4882a593Smuzhiyun * ib_get_cached_lmc - Returns a cached lmc table entry 84*4882a593Smuzhiyun * @device: The device to query. 85*4882a593Smuzhiyun * @port_num: The port number of the device to query. 86*4882a593Smuzhiyun * @lmc: The lmc value for the specified port for that device. 87*4882a593Smuzhiyun * 88*4882a593Smuzhiyun * ib_get_cached_lmc() fetches the specified lmc table entry stored in 89*4882a593Smuzhiyun * the local software cache. 90*4882a593Smuzhiyun */ 91*4882a593Smuzhiyun int ib_get_cached_lmc(struct ib_device *device, 92*4882a593Smuzhiyun u8 port_num, 93*4882a593Smuzhiyun u8 *lmc); 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun /** 96*4882a593Smuzhiyun * ib_get_cached_port_state - Returns a cached port state table entry 97*4882a593Smuzhiyun * @device: The device to query. 98*4882a593Smuzhiyun * @port_num: The port number of the device to query. 99*4882a593Smuzhiyun * @port_state: port_state for the specified port for that device. 100*4882a593Smuzhiyun * 101*4882a593Smuzhiyun * ib_get_cached_port_state() fetches the specified port_state table entry stored in 102*4882a593Smuzhiyun * the local software cache. 103*4882a593Smuzhiyun */ 104*4882a593Smuzhiyun int ib_get_cached_port_state(struct ib_device *device, 105*4882a593Smuzhiyun u8 port_num, 106*4882a593Smuzhiyun enum ib_port_state *port_active); 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun bool rdma_is_zero_gid(const union ib_gid *gid); 109*4882a593Smuzhiyun const struct ib_gid_attr *rdma_get_gid_attr(struct ib_device *device, 110*4882a593Smuzhiyun u8 port_num, int index); 111*4882a593Smuzhiyun void rdma_put_gid_attr(const struct ib_gid_attr *attr); 112*4882a593Smuzhiyun void rdma_hold_gid_attr(const struct ib_gid_attr *attr); 113*4882a593Smuzhiyun ssize_t rdma_query_gid_table(struct ib_device *device, 114*4882a593Smuzhiyun struct ib_uverbs_gid_entry *entries, 115*4882a593Smuzhiyun size_t max_entries); 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun #endif /* _IB_CACHE_H */ 118