xref: /kernel/linux/linux-6.6/include/rdma/ib_cache.h (revision 62306a36)
162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2004 Topspin Communications.  All rights reserved.
462306a36Sopenharmony_ci * Copyright (c) 2005 Intel Corporation. All rights reserved.
562306a36Sopenharmony_ci * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef _IB_CACHE_H
962306a36Sopenharmony_ci#define _IB_CACHE_H
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <rdma/ib_verbs.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciint rdma_query_gid(struct ib_device *device, u32 port_num, int index,
1462306a36Sopenharmony_ci		   union ib_gid *gid);
1562306a36Sopenharmony_civoid *rdma_read_gid_hw_context(const struct ib_gid_attr *attr);
1662306a36Sopenharmony_ciconst struct ib_gid_attr *rdma_find_gid(struct ib_device *device,
1762306a36Sopenharmony_ci					const union ib_gid *gid,
1862306a36Sopenharmony_ci					enum ib_gid_type gid_type,
1962306a36Sopenharmony_ci					struct net_device *ndev);
2062306a36Sopenharmony_ciconst struct ib_gid_attr *rdma_find_gid_by_port(struct ib_device *ib_dev,
2162306a36Sopenharmony_ci						const union ib_gid *gid,
2262306a36Sopenharmony_ci						enum ib_gid_type gid_type,
2362306a36Sopenharmony_ci						u32 port,
2462306a36Sopenharmony_ci						struct net_device *ndev);
2562306a36Sopenharmony_ciconst struct ib_gid_attr *rdma_find_gid_by_filter(
2662306a36Sopenharmony_ci	struct ib_device *device, const union ib_gid *gid, u32 port_num,
2762306a36Sopenharmony_ci	bool (*filter)(const union ib_gid *gid, const struct ib_gid_attr *,
2862306a36Sopenharmony_ci		       void *),
2962306a36Sopenharmony_ci	void *context);
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ciint rdma_read_gid_l2_fields(const struct ib_gid_attr *attr,
3262306a36Sopenharmony_ci			    u16 *vlan_id, u8 *smac);
3362306a36Sopenharmony_cistruct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr);
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci/**
3662306a36Sopenharmony_ci * ib_get_cached_pkey - Returns a cached PKey table entry
3762306a36Sopenharmony_ci * @device: The device to query.
3862306a36Sopenharmony_ci * @port_num: The port number of the device to query.
3962306a36Sopenharmony_ci * @index: The index into the cached PKey table to query.
4062306a36Sopenharmony_ci * @pkey: The PKey value found at the specified index.
4162306a36Sopenharmony_ci *
4262306a36Sopenharmony_ci * ib_get_cached_pkey() fetches the specified PKey table entry stored in
4362306a36Sopenharmony_ci * the local software cache.
4462306a36Sopenharmony_ci */
4562306a36Sopenharmony_ciint ib_get_cached_pkey(struct ib_device    *device_handle,
4662306a36Sopenharmony_ci		       u32                  port_num,
4762306a36Sopenharmony_ci		       int                  index,
4862306a36Sopenharmony_ci		       u16                 *pkey);
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci/**
5162306a36Sopenharmony_ci * ib_find_cached_pkey - Returns the PKey table index where a specified
5262306a36Sopenharmony_ci *   PKey value occurs.
5362306a36Sopenharmony_ci * @device: The device to query.
5462306a36Sopenharmony_ci * @port_num: The port number of the device to search for the PKey.
5562306a36Sopenharmony_ci * @pkey: The PKey value to search for.
5662306a36Sopenharmony_ci * @index: The index into the cached PKey table where the PKey was found.
5762306a36Sopenharmony_ci *
5862306a36Sopenharmony_ci * ib_find_cached_pkey() searches the specified PKey table in
5962306a36Sopenharmony_ci * the local software cache.
6062306a36Sopenharmony_ci */
6162306a36Sopenharmony_ciint ib_find_cached_pkey(struct ib_device    *device,
6262306a36Sopenharmony_ci			u32                  port_num,
6362306a36Sopenharmony_ci			u16                  pkey,
6462306a36Sopenharmony_ci			u16                 *index);
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci/**
6762306a36Sopenharmony_ci * ib_find_exact_cached_pkey - Returns the PKey table index where a specified
6862306a36Sopenharmony_ci *   PKey value occurs. Comparison uses the FULL 16 bits (incl membership bit)
6962306a36Sopenharmony_ci * @device: The device to query.
7062306a36Sopenharmony_ci * @port_num: The port number of the device to search for the PKey.
7162306a36Sopenharmony_ci * @pkey: The PKey value to search for.
7262306a36Sopenharmony_ci * @index: The index into the cached PKey table where the PKey was found.
7362306a36Sopenharmony_ci *
7462306a36Sopenharmony_ci * ib_find_exact_cached_pkey() searches the specified PKey table in
7562306a36Sopenharmony_ci * the local software cache.
7662306a36Sopenharmony_ci */
7762306a36Sopenharmony_ciint ib_find_exact_cached_pkey(struct ib_device    *device,
7862306a36Sopenharmony_ci			      u32                  port_num,
7962306a36Sopenharmony_ci			      u16                  pkey,
8062306a36Sopenharmony_ci			      u16                 *index);
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci/**
8362306a36Sopenharmony_ci * ib_get_cached_lmc - Returns a cached lmc table entry
8462306a36Sopenharmony_ci * @device: The device to query.
8562306a36Sopenharmony_ci * @port_num: The port number of the device to query.
8662306a36Sopenharmony_ci * @lmc: The lmc value for the specified port for that device.
8762306a36Sopenharmony_ci *
8862306a36Sopenharmony_ci * ib_get_cached_lmc() fetches the specified lmc table entry stored in
8962306a36Sopenharmony_ci * the local software cache.
9062306a36Sopenharmony_ci */
9162306a36Sopenharmony_ciint ib_get_cached_lmc(struct ib_device *device,
9262306a36Sopenharmony_ci		      u32               port_num,
9362306a36Sopenharmony_ci		      u8                *lmc);
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci/**
9662306a36Sopenharmony_ci * ib_get_cached_port_state - Returns a cached port state table entry
9762306a36Sopenharmony_ci * @device: The device to query.
9862306a36Sopenharmony_ci * @port_num: The port number of the device to query.
9962306a36Sopenharmony_ci * @port_state: port_state for the specified port for that device.
10062306a36Sopenharmony_ci *
10162306a36Sopenharmony_ci * ib_get_cached_port_state() fetches the specified port_state table entry stored in
10262306a36Sopenharmony_ci * the local software cache.
10362306a36Sopenharmony_ci */
10462306a36Sopenharmony_ciint ib_get_cached_port_state(struct ib_device *device,
10562306a36Sopenharmony_ci			     u32               port_num,
10662306a36Sopenharmony_ci			      enum ib_port_state *port_active);
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_cibool rdma_is_zero_gid(const union ib_gid *gid);
10962306a36Sopenharmony_ciconst struct ib_gid_attr *rdma_get_gid_attr(struct ib_device *device,
11062306a36Sopenharmony_ci					    u32 port_num, int index);
11162306a36Sopenharmony_civoid rdma_put_gid_attr(const struct ib_gid_attr *attr);
11262306a36Sopenharmony_civoid rdma_hold_gid_attr(const struct ib_gid_attr *attr);
11362306a36Sopenharmony_cissize_t rdma_query_gid_table(struct ib_device *device,
11462306a36Sopenharmony_ci			     struct ib_uverbs_gid_entry *entries,
11562306a36Sopenharmony_ci			     size_t max_entries);
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci#endif /* _IB_CACHE_H */
118