/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */1/*2* Copyright (c) 2004 Topspin Communications. All rights reserved.3* Copyright (c) 2005 Intel Corporation. All rights reserved.4* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.5*/67#ifndef _IB_CACHE_H8#define _IB_CACHE_H910#include <rdma/ib_verbs.h>1112int rdma_query_gid(struct ib_device *device, u32 port_num, int index,13union ib_gid *gid);14void *rdma_read_gid_hw_context(const struct ib_gid_attr *attr);15const struct ib_gid_attr *rdma_find_gid(struct ib_device *device,16const union ib_gid *gid,17enum ib_gid_type gid_type,18struct net_device *ndev);19const struct ib_gid_attr *rdma_find_gid_by_port(struct ib_device *ib_dev,20const union ib_gid *gid,21enum ib_gid_type gid_type,22u32 port,23struct net_device *ndev);24const struct ib_gid_attr *rdma_find_gid_by_filter(25struct ib_device *device, const union ib_gid *gid, u32 port_num,26bool (*filter)(const union ib_gid *gid, const struct ib_gid_attr *,27void *),28void *context);2930int rdma_read_gid_l2_fields(const struct ib_gid_attr *attr,31u16 *vlan_id, u8 *smac);32struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr);3334/**35* ib_get_cached_pkey - Returns a cached PKey table entry36* @device: The device to query.37* @port_num: The port number of the device to query.38* @index: The index into the cached PKey table to query.39* @pkey: The PKey value found at the specified index.40*41* ib_get_cached_pkey() fetches the specified PKey table entry stored in42* the local software cache.43*/44int ib_get_cached_pkey(struct ib_device *device_handle,45u32 port_num,46int index,47u16 *pkey);4849/**50* ib_find_cached_pkey - Returns the PKey table index where a specified51* PKey value occurs.52* @device: The device to query.53* @port_num: The port number of the device to search for the PKey.54* @pkey: The PKey value to search for.55* @index: The index into the cached PKey table where the PKey was found.56*57* ib_find_cached_pkey() searches the specified PKey table in58* the local software cache.59*/60int ib_find_cached_pkey(struct ib_device *device,61u32 port_num,62u16 pkey,63u16 *index);6465/**66* ib_get_cached_lmc - Returns a cached lmc table entry67* @device: The device to query.68* @port_num: The port number of the device to query.69* @lmc: The lmc value for the specified port for that device.70*71* ib_get_cached_lmc() fetches the specified lmc table entry stored in72* the local software cache.73*/74int ib_get_cached_lmc(struct ib_device *device,75u32 port_num,76u8 *lmc);7778/**79* ib_get_cached_port_state - Returns a cached port state table entry80* @device: The device to query.81* @port_num: The port number of the device to query.82* @port_state: port_state for the specified port for that device.83*84* ib_get_cached_port_state() fetches the specified port_state table entry stored in85* the local software cache.86*/87int ib_get_cached_port_state(struct ib_device *device,88u32 port_num,89enum ib_port_state *port_active);9091bool rdma_is_zero_gid(const union ib_gid *gid);92const struct ib_gid_attr *rdma_get_gid_attr(struct ib_device *device,93u32 port_num, int index);94void rdma_put_gid_attr(const struct ib_gid_attr *attr);95void rdma_hold_gid_attr(const struct ib_gid_attr *attr);96ssize_t rdma_query_gid_table(struct ib_device *device,97struct ib_uverbs_gid_entry *entries,98size_t max_entries);99100#endif /* _IB_CACHE_H */101102103