xref: /linux-6.15/include/rdma/ib_cache.h (revision ddc8fab4)
16bf9d8f6SLeon Romanovsky /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2a4d61e84SRoland Dreier /*
3a4d61e84SRoland Dreier  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
4a4d61e84SRoland Dreier  * Copyright (c) 2005 Intel Corporation. All rights reserved.
5a4d61e84SRoland Dreier  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
6a4d61e84SRoland Dreier  */
7a4d61e84SRoland Dreier 
8a4d61e84SRoland Dreier #ifndef _IB_CACHE_H
9a4d61e84SRoland Dreier #define _IB_CACHE_H
10a4d61e84SRoland Dreier 
11a4d61e84SRoland Dreier #include <rdma/ib_verbs.h>
12a4d61e84SRoland Dreier 
13*1fb7f897SMark Bloch int rdma_query_gid(struct ib_device *device, u32 port_num, int index,
14c3d71b69SJason Gunthorpe 		   union ib_gid *gid);
15779820c2SSelvin Xavier void *rdma_read_gid_hw_context(const struct ib_gid_attr *attr);
16c3d71b69SJason Gunthorpe const struct ib_gid_attr *rdma_find_gid(struct ib_device *device,
17c3d71b69SJason Gunthorpe 					const union ib_gid *gid,
18c3d71b69SJason Gunthorpe 					enum ib_gid_type gid_type,
19c3d71b69SJason Gunthorpe 					struct net_device *ndev);
20c3d71b69SJason Gunthorpe const struct ib_gid_attr *rdma_find_gid_by_port(struct ib_device *ib_dev,
21c3d71b69SJason Gunthorpe 						const union ib_gid *gid,
22c3d71b69SJason Gunthorpe 						enum ib_gid_type gid_type,
23*1fb7f897SMark Bloch 						u32 port,
24c3d71b69SJason Gunthorpe 						struct net_device *ndev);
25c3d71b69SJason Gunthorpe const struct ib_gid_attr *rdma_find_gid_by_filter(
26*1fb7f897SMark Bloch 	struct ib_device *device, const union ib_gid *gid, u32 port_num,
27c3d71b69SJason Gunthorpe 	bool (*filter)(const union ib_gid *gid, const struct ib_gid_attr *,
28c3d71b69SJason Gunthorpe 		       void *),
29c3d71b69SJason Gunthorpe 	void *context);
30c3d71b69SJason Gunthorpe 
31a70c0739SParav Pandit int rdma_read_gid_l2_fields(const struct ib_gid_attr *attr,
32a70c0739SParav Pandit 			    u16 *vlan_id, u8 *smac);
33adb4a57aSParav Pandit struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr);
34a70c0739SParav Pandit 
35d300ec52SMatan Barak /**
36a4d61e84SRoland Dreier  * ib_get_cached_pkey - Returns a cached PKey table entry
37a4d61e84SRoland Dreier  * @device: The device to query.
38a4d61e84SRoland Dreier  * @port_num: The port number of the device to query.
39a4d61e84SRoland Dreier  * @index: The index into the cached PKey table to query.
40a4d61e84SRoland Dreier  * @pkey: The PKey value found at the specified index.
41a4d61e84SRoland Dreier  *
42a4d61e84SRoland Dreier  * ib_get_cached_pkey() fetches the specified PKey table entry stored in
43a4d61e84SRoland Dreier  * the local software cache.
44a4d61e84SRoland Dreier  */
45a4d61e84SRoland Dreier int ib_get_cached_pkey(struct ib_device    *device_handle,
46*1fb7f897SMark Bloch 		       u32                  port_num,
47a4d61e84SRoland Dreier 		       int                  index,
48a4d61e84SRoland Dreier 		       u16                 *pkey);
49a4d61e84SRoland Dreier 
50a4d61e84SRoland Dreier /**
51a4d61e84SRoland Dreier  * ib_find_cached_pkey - Returns the PKey table index where a specified
52a4d61e84SRoland Dreier  *   PKey value occurs.
53a4d61e84SRoland Dreier  * @device: The device to query.
54a4d61e84SRoland Dreier  * @port_num: The port number of the device to search for the PKey.
55a4d61e84SRoland Dreier  * @pkey: The PKey value to search for.
56a4d61e84SRoland Dreier  * @index: The index into the cached PKey table where the PKey was found.
57a4d61e84SRoland Dreier  *
58a4d61e84SRoland Dreier  * ib_find_cached_pkey() searches the specified PKey table in
59a4d61e84SRoland Dreier  * the local software cache.
60a4d61e84SRoland Dreier  */
61a4d61e84SRoland Dreier int ib_find_cached_pkey(struct ib_device    *device,
62*1fb7f897SMark Bloch 			u32                  port_num,
63a4d61e84SRoland Dreier 			u16                  pkey,
64a4d61e84SRoland Dreier 			u16                 *index);
65a4d61e84SRoland Dreier 
666fb9cdbfSJack Morgenstein /**
676fb9cdbfSJack Morgenstein  * ib_get_cached_lmc - Returns a cached lmc table entry
686fb9cdbfSJack Morgenstein  * @device: The device to query.
696fb9cdbfSJack Morgenstein  * @port_num: The port number of the device to query.
706fb9cdbfSJack Morgenstein  * @lmc: The lmc value for the specified port for that device.
716fb9cdbfSJack Morgenstein  *
726fb9cdbfSJack Morgenstein  * ib_get_cached_lmc() fetches the specified lmc table entry stored in
736fb9cdbfSJack Morgenstein  * the local software cache.
746fb9cdbfSJack Morgenstein  */
756fb9cdbfSJack Morgenstein int ib_get_cached_lmc(struct ib_device *device,
76*1fb7f897SMark Bloch 		      u32               port_num,
776fb9cdbfSJack Morgenstein 		      u8                *lmc);
786fb9cdbfSJack Morgenstein 
799e2c3f1cSJack Wang /**
809e2c3f1cSJack Wang  * ib_get_cached_port_state - Returns a cached port state table entry
819e2c3f1cSJack Wang  * @device: The device to query.
829e2c3f1cSJack Wang  * @port_num: The port number of the device to query.
839e2c3f1cSJack Wang  * @port_state: port_state for the specified port for that device.
849e2c3f1cSJack Wang  *
859e2c3f1cSJack Wang  * ib_get_cached_port_state() fetches the specified port_state table entry stored in
869e2c3f1cSJack Wang  * the local software cache.
879e2c3f1cSJack Wang  */
889e2c3f1cSJack Wang int ib_get_cached_port_state(struct ib_device *device,
89*1fb7f897SMark Bloch 			     u32               port_num,
909e2c3f1cSJack Wang 			      enum ib_port_state *port_active);
919e2c3f1cSJack Wang 
9225e62655SParav Pandit bool rdma_is_zero_gid(const union ib_gid *gid);
93bf399c2cSParav Pandit const struct ib_gid_attr *rdma_get_gid_attr(struct ib_device *device,
94*1fb7f897SMark Bloch 					    u32 port_num, int index);
95bf399c2cSParav Pandit void rdma_put_gid_attr(const struct ib_gid_attr *attr);
96bf399c2cSParav Pandit void rdma_hold_gid_attr(const struct ib_gid_attr *attr);
97c4b4d548SAvihai Horon ssize_t rdma_query_gid_table(struct ib_device *device,
98c4b4d548SAvihai Horon 			     struct ib_uverbs_gid_entry *entries,
99c4b4d548SAvihai Horon 			     size_t max_entries);
1007aaa1807SJason Gunthorpe 
101a4d61e84SRoland Dreier #endif /* _IB_CACHE_H */
102