xref: /freebsd/sys/ofed/include/rdma/ib_cache.h (revision e6bfd18d21b225af6a0ed67ceeaf1293b7b9eba5)
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  * $FreeBSD$
37  */
38 
39 #ifndef _IB_CACHE_H
40 #define _IB_CACHE_H
41 
42 #include <rdma/ib_verbs.h>
43 
44 /**
45  * ib_get_cached_gid - Returns a cached GID table entry
46  * @device: The device to query.
47  * @port_num: The port number of the device to query.
48  * @index: The index into the cached GID table to query.
49  * @gid: The GID value found at the specified index.
50  * @attr: The GID attribute found at the specified index (only in RoCE).
51  *   NULL means ignore (output parameter).
52  *
53  * ib_get_cached_gid() fetches the specified GID table entry stored in
54  * the local software cache.
55  */
56 int ib_get_cached_gid(struct ib_device    *device,
57 		      u8                   port_num,
58 		      int                  index,
59 		      union ib_gid        *gid,
60 		      struct ib_gid_attr  *attr);
61 
62 /**
63  * ib_find_cached_gid - Returns the port number and GID table index where
64  *   a specified GID value occurs.
65  * @device: The device to query.
66  * @gid: The GID value to search for.
67  * @gid_type: The GID type to search for.
68  * @ndev: In RoCE, the net device of the device. NULL means ignore.
69  * @port_num: The port number of the device where the GID value was found.
70  * @index: The index into the cached GID table where the GID was found.  This
71  *   parameter may be NULL.
72  *
73  * ib_find_cached_gid() searches for the specified GID value in
74  * the local software cache.
75  */
76 int ib_find_cached_gid(struct ib_device *device,
77 		       const union ib_gid *gid,
78 		       enum ib_gid_type gid_type,
79 		       if_t              ndev,
80 		       u8               *port_num,
81 		       u16              *index);
82 
83 /**
84  * ib_find_cached_gid_by_port - Returns the GID table index where a specified
85  * GID value occurs
86  * @device: The device to query.
87  * @gid: The GID value to search for.
88  * @gid_type: The GID type to search for.
89  * @port_num: The port number of the device where the GID value sould be
90  *   searched.
91  * @ndev: In RoCE, the net device of the device. Null means ignore.
92  * @index: The index into the cached GID table where the GID was found.  This
93  *   parameter may be NULL.
94  *
95  * ib_find_cached_gid() searches for the specified GID value in
96  * the local software cache.
97  */
98 int ib_find_cached_gid_by_port(struct ib_device *device,
99 			       const union ib_gid *gid,
100 			       enum ib_gid_type gid_type,
101 			       u8               port_num,
102 			       if_t             ndev,
103 			       u16              *index);
104 
105 int ib_find_gid_by_filter(struct ib_device *device,
106 			  const union ib_gid *gid,
107 			  u8 port_num,
108 			  bool (*filter)(const union ib_gid *gid,
109 					 const struct ib_gid_attr *,
110 					 void *),
111 			  void *context, u16 *index);
112 /**
113  * ib_get_cached_pkey - Returns a cached PKey table entry
114  * @device: The device to query.
115  * @port_num: The port number of the device to query.
116  * @index: The index into the cached PKey table to query.
117  * @pkey: The PKey value found at the specified index.
118  *
119  * ib_get_cached_pkey() fetches the specified PKey table entry stored in
120  * the local software cache.
121  */
122 int ib_get_cached_pkey(struct ib_device    *device_handle,
123 		       u8                   port_num,
124 		       int                  index,
125 		       u16                 *pkey);
126 
127 /**
128  * ib_find_cached_pkey - Returns the PKey table index where a specified
129  *   PKey value occurs.
130  * @device: The device to query.
131  * @port_num: The port number of the device to search for the PKey.
132  * @pkey: The PKey value to search for.
133  * @index: The index into the cached PKey table where the PKey was found.
134  *
135  * ib_find_cached_pkey() searches the specified PKey table in
136  * the local software cache.
137  */
138 int ib_find_cached_pkey(struct ib_device    *device,
139 			u8                   port_num,
140 			u16                  pkey,
141 			u16                 *index);
142 
143 /**
144  * ib_find_exact_cached_pkey - Returns the PKey table index where a specified
145  *   PKey value occurs. Comparison uses the FULL 16 bits (incl membership bit)
146  * @device: The device to query.
147  * @port_num: The port number of the device to search for the PKey.
148  * @pkey: The PKey value to search for.
149  * @index: The index into the cached PKey table where the PKey was found.
150  *
151  * ib_find_exact_cached_pkey() searches the specified PKey table in
152  * the local software cache.
153  */
154 int ib_find_exact_cached_pkey(struct ib_device    *device,
155 			      u8                   port_num,
156 			      u16                  pkey,
157 			      u16                 *index);
158 
159 /**
160  * ib_get_cached_lmc - Returns a cached lmc table entry
161  * @device: The device to query.
162  * @port_num: The port number of the device to query.
163  * @lmc: The lmc value for the specified port for that device.
164  *
165  * ib_get_cached_lmc() fetches the specified lmc table entry stored in
166  * the local software cache.
167  */
168 int ib_get_cached_lmc(struct ib_device *device,
169 		      u8                port_num,
170 		      u8                *lmc);
171 
172 #endif /* _IB_CACHE_H */
173