blob: 269a27cf0a46f37c7fd9fdc3fc24df2d5070c2d2 [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);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58/**
59 * ib_find_cached_gid - Returns the port number and GID table index where
60 * a specified GID value occurs.
61 * @device: The device to query.
62 * @gid: The GID value to search for.
Matan Barak55ee3ab2015-10-15 18:38:45 +030063 * @ndev: In RoCE, the net device of the device. NULL means ignore.
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 * @port_num: The port number of the device where the GID value was found.
65 * @index: The index into the cached GID table where the GID was found. This
66 * parameter may be NULL.
67 *
68 * ib_find_cached_gid() searches for the specified GID value in
69 * the local software cache.
70 */
Matan Barak55ee3ab2015-10-15 18:38:45 +030071int ib_find_cached_gid(struct ib_device *device,
Ira Weiny73cdaae2015-05-31 17:15:31 -040072 const union ib_gid *gid,
Matan Barak55ee3ab2015-10-15 18:38:45 +030073 struct net_device *ndev,
74 u8 *port_num,
75 u16 *index);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
77/**
Matan Barakd300ec52015-10-15 18:38:46 +030078 * ib_find_cached_gid_by_port - Returns the GID table index where a specified
79 * GID value occurs
80 * @device: The device to query.
81 * @gid: The GID value to search for.
82 * @port_num: The port number of the device where the GID value sould be
83 * searched.
84 * @ndev: In RoCE, the net device of the device. Null means ignore.
85 * @index: The index into the cached GID table where the GID was found. This
86 * parameter may be NULL.
87 *
88 * ib_find_cached_gid() searches for the specified GID value in
89 * the local software cache.
90 */
91int ib_find_cached_gid_by_port(struct ib_device *device,
92 const union ib_gid *gid,
93 u8 port_num,
94 struct net_device *ndev,
95 u16 *index);
Matan Barak99b27e32015-10-15 18:38:50 +030096
97int ib_find_gid_by_filter(struct ib_device *device,
98 const union ib_gid *gid,
99 u8 port_num,
100 bool (*filter)(const union ib_gid *gid,
101 const struct ib_gid_attr *,
102 void *),
103 void *context, u16 *index);
Matan Barakd300ec52015-10-15 18:38:46 +0300104/**
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 * ib_get_cached_pkey - Returns a cached PKey table entry
106 * @device: The device to query.
107 * @port_num: The port number of the device to query.
108 * @index: The index into the cached PKey table to query.
109 * @pkey: The PKey value found at the specified index.
110 *
111 * ib_get_cached_pkey() fetches the specified PKey table entry stored in
112 * the local software cache.
113 */
114int ib_get_cached_pkey(struct ib_device *device_handle,
115 u8 port_num,
116 int index,
117 u16 *pkey);
118
119/**
120 * ib_find_cached_pkey - Returns the PKey table index where a specified
121 * PKey value occurs.
122 * @device: The device to query.
123 * @port_num: The port number of the device to search for the PKey.
124 * @pkey: The PKey value to search for.
125 * @index: The index into the cached PKey table where the PKey was found.
126 *
127 * ib_find_cached_pkey() searches the specified PKey table in
128 * the local software cache.
129 */
130int ib_find_cached_pkey(struct ib_device *device,
131 u8 port_num,
132 u16 pkey,
133 u16 *index);
134
Jack Morgenstein6fb9cdb2006-06-17 20:37:34 -0700135/**
Jack Morgenstein73aaa742012-08-03 08:40:39 +0000136 * ib_find_exact_cached_pkey - Returns the PKey table index where a specified
137 * PKey value occurs. Comparison uses the FULL 16 bits (incl membership bit)
138 * @device: The device to query.
139 * @port_num: The port number of the device to search for the PKey.
140 * @pkey: The PKey value to search for.
141 * @index: The index into the cached PKey table where the PKey was found.
142 *
143 * ib_find_exact_cached_pkey() searches the specified PKey table in
144 * the local software cache.
145 */
146int ib_find_exact_cached_pkey(struct ib_device *device,
147 u8 port_num,
148 u16 pkey,
149 u16 *index);
150
151/**
Jack Morgenstein6fb9cdb2006-06-17 20:37:34 -0700152 * ib_get_cached_lmc - Returns a cached lmc table entry
153 * @device: The device to query.
154 * @port_num: The port number of the device to query.
155 * @lmc: The lmc value for the specified port for that device.
156 *
157 * ib_get_cached_lmc() fetches the specified lmc table entry stored in
158 * the local software cache.
159 */
160int ib_get_cached_lmc(struct ib_device *device,
161 u8 port_num,
162 u8 *lmc);
163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164#endif /* _IB_CACHE_H */