xref: /freebsd/sys/ofed/include/rdma/ib_cache.h (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3  *
4  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
5  * Copyright (c) 2005 Intel Corporation. All rights reserved.
6  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
7  *
8  * This software is available to you under a choice of one of two
9  * licenses.  You may choose to be licensed under the terms of the GNU
10  * General Public License (GPL) Version 2, available from the file
11  * COPYING in the main directory of this source tree, or the
12  * OpenIB.org BSD license below:
13  *
14  *     Redistribution and use in source and binary forms, with or
15  *     without modification, are permitted provided that the following
16  *     conditions are met:
17  *
18  *      - Redistributions of source code must retain the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer.
21  *
22  *      - Redistributions in binary form must reproduce the above
23  *        copyright notice, this list of conditions and the following
24  *        disclaimer in the documentation and/or other materials
25  *        provided with the distribution.
26  *
27  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
31  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
32  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34  * SOFTWARE.
35  */
36 
37 #ifndef _IB_CACHE_H
38 #define _IB_CACHE_H
39 
40 #include <rdma/ib_verbs.h>
41 
42 /**
43  * ib_get_cached_gid - Returns a cached GID table entry
44  * @device: The device to query.
45  * @port_num: The port number of the device to query.
46  * @index: The index into the cached GID table to query.
47  * @gid: The GID value found at the specified index.
48  * @attr: The GID attribute found at the specified index (only in RoCE).
49  *   NULL means ignore (output parameter).
50  *
51  * ib_get_cached_gid() fetches the specified GID table entry stored in
52  * the local software cache.
53  */
54 int ib_get_cached_gid(struct ib_device    *device,
55 		      u8                   port_num,
56 		      int                  index,
57 		      union ib_gid        *gid,
58 		      struct ib_gid_attr  *attr);
59 
60 /**
61  * ib_find_cached_gid - Returns the port number and GID table index where
62  *   a specified GID value occurs.
63  * @device: The device to query.
64  * @gid: The GID value to search for.
65  * @gid_type: The GID type to search for.
66  * @ndev: In RoCE, the net device of the device. NULL means ignore.
67  * @port_num: The port number of the device where the GID value was found.
68  * @index: The index into the cached GID table where the GID was found.  This
69  *   parameter may be NULL.
70  *
71  * ib_find_cached_gid() searches for the specified GID value in
72  * the local software cache.
73  */
74 int ib_find_cached_gid(struct ib_device *device,
75 		       const union ib_gid *gid,
76 		       enum ib_gid_type gid_type,
77 		       if_t              ndev,
78 		       u8               *port_num,
79 		       u16              *index);
80 
81 /**
82  * ib_find_cached_gid_by_port - Returns the GID table index where a specified
83  * GID value occurs
84  * @device: The device to query.
85  * @gid: The GID value to search for.
86  * @gid_type: The GID type to search for.
87  * @port_num: The port number of the device where the GID value sould be
88  *   searched.
89  * @ndev: In RoCE, the net device of the device. Null means ignore.
90  * @index: The index into the cached GID table where the GID was found.  This
91  *   parameter may be NULL.
92  *
93  * ib_find_cached_gid() searches for the specified GID value in
94  * the local software cache.
95  */
96 int ib_find_cached_gid_by_port(struct ib_device *device,
97 			       const union ib_gid *gid,
98 			       enum ib_gid_type gid_type,
99 			       u8               port_num,
100 			       if_t             ndev,
101 			       u16              *index);
102 
103 int ib_find_gid_by_filter(struct ib_device *device,
104 			  const union ib_gid *gid,
105 			  u8 port_num,
106 			  bool (*filter)(const union ib_gid *gid,
107 					 const struct ib_gid_attr *,
108 					 void *),
109 			  void *context, u16 *index);
110 /**
111  * ib_get_cached_pkey - Returns a cached PKey table entry
112  * @device: The device to query.
113  * @port_num: The port number of the device to query.
114  * @index: The index into the cached PKey table to query.
115  * @pkey: The PKey value found at the specified index.
116  *
117  * ib_get_cached_pkey() fetches the specified PKey table entry stored in
118  * the local software cache.
119  */
120 int ib_get_cached_pkey(struct ib_device    *device_handle,
121 		       u8                   port_num,
122 		       int                  index,
123 		       u16                 *pkey);
124 
125 /**
126  * ib_find_cached_pkey - Returns the PKey table index where a specified
127  *   PKey value occurs.
128  * @device: The device to query.
129  * @port_num: The port number of the device to search for the PKey.
130  * @pkey: The PKey value to search for.
131  * @index: The index into the cached PKey table where the PKey was found.
132  *
133  * ib_find_cached_pkey() searches the specified PKey table in
134  * the local software cache.
135  */
136 int ib_find_cached_pkey(struct ib_device    *device,
137 			u8                   port_num,
138 			u16                  pkey,
139 			u16                 *index);
140 
141 /**
142  * ib_find_exact_cached_pkey - Returns the PKey table index where a specified
143  *   PKey value occurs. Comparison uses the FULL 16 bits (incl membership bit)
144  * @device: The device to query.
145  * @port_num: The port number of the device to search for the PKey.
146  * @pkey: The PKey value to search for.
147  * @index: The index into the cached PKey table where the PKey was found.
148  *
149  * ib_find_exact_cached_pkey() searches the specified PKey table in
150  * the local software cache.
151  */
152 int ib_find_exact_cached_pkey(struct ib_device    *device,
153 			      u8                   port_num,
154 			      u16                  pkey,
155 			      u16                 *index);
156 
157 /**
158  * ib_get_cached_lmc - Returns a cached lmc table entry
159  * @device: The device to query.
160  * @port_num: The port number of the device to query.
161  * @lmc: The lmc value for the specified port for that device.
162  *
163  * ib_get_cached_lmc() fetches the specified lmc table entry stored in
164  * the local software cache.
165  */
166 int ib_get_cached_lmc(struct ib_device *device,
167 		      u8                port_num,
168 		      u8                *lmc);
169 
170 #endif /* _IB_CACHE_H */
171