blob: 059f7d894939669085256812c6f7720e0e5045d2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (c) 2004 Topspin Communications. All rights reserved.
Roland Dreier2a1d9b72005-08-10 23:03:10 -07003 * Copyright (c) 2005 Intel Corporation. All rights reserved.
4 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 */
34
35#ifndef _IB_CACHE_H
36#define _IB_CACHE_H
37
Roland Dreiera4d61e82005-08-25 13:40:04 -070038#include <rdma/ib_verbs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/**
41 * ib_get_cached_gid - Returns a cached GID table entry
42 * @device: The device to query.
43 * @port_num: The port number of the device to query.
44 * @index: The index into the cached GID table to query.
45 * @gid: The GID value found at the specified index.
Matan Barak55ee3ab2015-10-15 18:38:45 +030046 * @attr: The GID attribute found at the specified index (only in RoCE).
47 * NULL means ignore (output parameter).
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 *
49 * ib_get_cached_gid() fetches the specified GID table entry stored in
50 * the local software cache.
51 */
52int ib_get_cached_gid(struct ib_device *device,
53 u8 port_num,
54 int index,
Matan Barak55ee3ab2015-10-15 18:38:45 +030055 union ib_gid *gid,
56 struct ib_gid_attr *attr);
Jason Gunthorpec3d71b62018-06-05 08:40:20 +030057int rdma_query_gid(struct ib_device *device, u8 port_num, int index,
58 union ib_gid *gid);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
Matan Barak55ee3ab2015-10-15 18:38:45 +030060int ib_find_cached_gid(struct ib_device *device,
Ira Weiny73cdaae2015-05-31 17:15:31 -040061 const union ib_gid *gid,
Matan Barakb39ffa12015-12-23 14:56:47 +020062 enum ib_gid_type gid_type,
Matan Barak55ee3ab2015-10-15 18:38:45 +030063 struct net_device *ndev,
64 u8 *port_num,
65 u16 *index);
Jason Gunthorpec3d71b62018-06-05 08:40:20 +030066const struct ib_gid_attr *rdma_find_gid(struct ib_device *device,
67 const union ib_gid *gid,
68 enum ib_gid_type gid_type,
69 struct net_device *ndev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Matan Barakd300ec52015-10-15 18:38:46 +030071int ib_find_cached_gid_by_port(struct ib_device *device,
72 const union ib_gid *gid,
Matan Barakb39ffa12015-12-23 14:56:47 +020073 enum ib_gid_type gid_type,
Matan Barakd300ec52015-10-15 18:38:46 +030074 u8 port_num,
75 struct net_device *ndev,
76 u16 *index);
Jason Gunthorpec3d71b62018-06-05 08:40:20 +030077const struct ib_gid_attr *rdma_find_gid_by_port(struct ib_device *ib_dev,
78 const union ib_gid *gid,
79 enum ib_gid_type gid_type,
80 u8 port,
81 struct net_device *ndev);
Matan Barak99b27e32015-10-15 18:38:50 +030082
83int ib_find_gid_by_filter(struct ib_device *device,
84 const union ib_gid *gid,
85 u8 port_num,
86 bool (*filter)(const union ib_gid *gid,
87 const struct ib_gid_attr *,
88 void *),
89 void *context, u16 *index);
Jason Gunthorpec3d71b62018-06-05 08:40:20 +030090const struct ib_gid_attr *rdma_find_gid_by_filter(
91 struct ib_device *device, const union ib_gid *gid, u8 port_num,
92 bool (*filter)(const union ib_gid *gid, const struct ib_gid_attr *,
93 void *),
94 void *context);
95
Matan Barakd300ec52015-10-15 18:38:46 +030096/**
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 * ib_get_cached_pkey - Returns a cached PKey table entry
98 * @device: The device to query.
99 * @port_num: The port number of the device to query.
100 * @index: The index into the cached PKey table to query.
101 * @pkey: The PKey value found at the specified index.
102 *
103 * ib_get_cached_pkey() fetches the specified PKey table entry stored in
104 * the local software cache.
105 */
106int ib_get_cached_pkey(struct ib_device *device_handle,
107 u8 port_num,
108 int index,
109 u16 *pkey);
110
111/**
112 * ib_find_cached_pkey - Returns the PKey table index where a specified
113 * PKey value occurs.
114 * @device: The device to query.
115 * @port_num: The port number of the device to search for the PKey.
116 * @pkey: The PKey value to search for.
117 * @index: The index into the cached PKey table where the PKey was found.
118 *
119 * ib_find_cached_pkey() searches the specified PKey table in
120 * the local software cache.
121 */
122int ib_find_cached_pkey(struct ib_device *device,
123 u8 port_num,
124 u16 pkey,
125 u16 *index);
126
Jack Morgenstein6fb9cdb2006-06-17 20:37:34 -0700127/**
Jack Morgenstein73aaa742012-08-03 08:40:39 +0000128 * ib_find_exact_cached_pkey - Returns the PKey table index where a specified
129 * PKey value occurs. Comparison uses the FULL 16 bits (incl membership bit)
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_exact_cached_pkey() searches the specified PKey table in
136 * the local software cache.
137 */
138int ib_find_exact_cached_pkey(struct ib_device *device,
139 u8 port_num,
140 u16 pkey,
141 u16 *index);
142
143/**
Jack Morgenstein6fb9cdb2006-06-17 20:37:34 -0700144 * ib_get_cached_lmc - Returns a cached lmc table entry
145 * @device: The device to query.
146 * @port_num: The port number of the device to query.
147 * @lmc: The lmc value for the specified port for that device.
148 *
149 * ib_get_cached_lmc() fetches the specified lmc table entry stored in
150 * the local software cache.
151 */
152int ib_get_cached_lmc(struct ib_device *device,
153 u8 port_num,
154 u8 *lmc);
155
Jack Wang9e2c3f12017-01-02 13:19:24 +0100156/**
157 * ib_get_cached_port_state - Returns a cached port state table entry
158 * @device: The device to query.
159 * @port_num: The port number of the device to query.
160 * @port_state: port_state for the specified port for that device.
161 *
162 * ib_get_cached_port_state() fetches the specified port_state table entry stored in
163 * the local software cache.
164 */
165int ib_get_cached_port_state(struct ib_device *device,
166 u8 port_num,
167 enum ib_port_state *port_active);
168
Parav Pandit25e62652018-05-22 20:33:45 +0300169bool rdma_is_zero_gid(const union ib_gid *gid);
Parav Panditbf399c22018-06-05 08:40:17 +0300170const struct ib_gid_attr *rdma_get_gid_attr(struct ib_device *device,
171 u8 port_num, int index);
172void rdma_put_gid_attr(const struct ib_gid_attr *attr);
173void rdma_hold_gid_attr(const struct ib_gid_attr *attr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174#endif /* _IB_CACHE_H */