/*-1* SPDX-License-Identifier: BSD-2-Clause OR GPL-2.02*3* Copyright (c) 2004 Topspin Communications. All rights reserved.4* Copyright (c) 2005 Intel Corporation. All rights reserved.5* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.6*7* This software is available to you under a choice of one of two8* licenses. You may choose to be licensed under the terms of the GNU9* General Public License (GPL) Version 2, available from the file10* COPYING in the main directory of this source tree, or the11* OpenIB.org BSD license below:12*13* Redistribution and use in source and binary forms, with or14* without modification, are permitted provided that the following15* conditions are met:16*17* - Redistributions of source code must retain the above18* copyright notice, this list of conditions and the following19* disclaimer.20*21* - Redistributions in binary form must reproduce the above22* copyright notice, this list of conditions and the following23* disclaimer in the documentation and/or other materials24* provided with the distribution.25*26* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,27* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF28* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND29* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS30* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN31* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN32* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE33* SOFTWARE.34*/3536#ifndef _IB_CACHE_H37#define _IB_CACHE_H3839#include <rdma/ib_verbs.h>4041/**42* ib_get_cached_gid - Returns a cached GID table entry43* @device: The device to query.44* @port_num: The port number of the device to query.45* @index: The index into the cached GID table to query.46* @gid: The GID value found at the specified index.47* @attr: The GID attribute found at the specified index (only in RoCE).48* NULL means ignore (output parameter).49*50* ib_get_cached_gid() fetches the specified GID table entry stored in51* the local software cache.52*/53int ib_get_cached_gid(struct ib_device *device,54u8 port_num,55int index,56union ib_gid *gid,57struct ib_gid_attr *attr);5859/**60* ib_find_cached_gid - Returns the port number and GID table index where61* a specified GID value occurs.62* @device: The device to query.63* @gid: The GID value to search for.64* @gid_type: The GID type to search for.65* @ndev: In RoCE, the net device of the device. NULL means ignore.66* @port_num: The port number of the device where the GID value was found.67* @index: The index into the cached GID table where the GID was found. This68* parameter may be NULL.69*70* ib_find_cached_gid() searches for the specified GID value in71* the local software cache.72*/73int ib_find_cached_gid(struct ib_device *device,74const union ib_gid *gid,75enum ib_gid_type gid_type,76if_t ndev,77u8 *port_num,78u16 *index);7980/**81* ib_find_cached_gid_by_port - Returns the GID table index where a specified82* GID value occurs83* @device: The device to query.84* @gid: The GID value to search for.85* @gid_type: The GID type to search for.86* @port_num: The port number of the device where the GID value sould be87* searched.88* @ndev: In RoCE, the net device of the device. Null means ignore.89* @index: The index into the cached GID table where the GID was found. This90* parameter may be NULL.91*92* ib_find_cached_gid() searches for the specified GID value in93* the local software cache.94*/95int ib_find_cached_gid_by_port(struct ib_device *device,96const union ib_gid *gid,97enum ib_gid_type gid_type,98u8 port_num,99if_t ndev,100u16 *index);101102int ib_find_gid_by_filter(struct ib_device *device,103const union ib_gid *gid,104u8 port_num,105bool (*filter)(const union ib_gid *gid,106const struct ib_gid_attr *,107void *),108void *context, u16 *index);109/**110* ib_get_cached_pkey - Returns a cached PKey table entry111* @device: The device to query.112* @port_num: The port number of the device to query.113* @index: The index into the cached PKey table to query.114* @pkey: The PKey value found at the specified index.115*116* ib_get_cached_pkey() fetches the specified PKey table entry stored in117* the local software cache.118*/119int ib_get_cached_pkey(struct ib_device *device_handle,120u8 port_num,121int index,122u16 *pkey);123124/**125* ib_find_cached_pkey - Returns the PKey table index where a specified126* PKey value occurs.127* @device: The device to query.128* @port_num: The port number of the device to search for the PKey.129* @pkey: The PKey value to search for.130* @index: The index into the cached PKey table where the PKey was found.131*132* ib_find_cached_pkey() searches the specified PKey table in133* the local software cache.134*/135int ib_find_cached_pkey(struct ib_device *device,136u8 port_num,137u16 pkey,138u16 *index);139140/**141* ib_find_exact_cached_pkey - Returns the PKey table index where a specified142* PKey value occurs. Comparison uses the FULL 16 bits (incl membership bit)143* @device: The device to query.144* @port_num: The port number of the device to search for the PKey.145* @pkey: The PKey value to search for.146* @index: The index into the cached PKey table where the PKey was found.147*148* ib_find_exact_cached_pkey() searches the specified PKey table in149* the local software cache.150*/151int ib_find_exact_cached_pkey(struct ib_device *device,152u8 port_num,153u16 pkey,154u16 *index);155156/**157* ib_get_cached_lmc - Returns a cached lmc table entry158* @device: The device to query.159* @port_num: The port number of the device to query.160* @lmc: The lmc value for the specified port for that device.161*162* ib_get_cached_lmc() fetches the specified lmc table entry stored in163* the local software cache.164*/165int ib_get_cached_lmc(struct ib_device *device,166u8 port_num,167u8 *lmc);168169#endif /* _IB_CACHE_H */170171172