blob: e06d13388ae716ddd65640c26dd64599ed71ed81 [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
Jason Gunthorpec3d71b62018-06-05 08:40:20 +030040int rdma_query_gid(struct ib_device *device, u8 port_num, int index,
41 union ib_gid *gid);
Selvin Xavier779820c2020-02-19 02:19:53 -080042void *rdma_read_gid_hw_context(const struct ib_gid_attr *attr);
Jason Gunthorpec3d71b62018-06-05 08:40:20 +030043const struct ib_gid_attr *rdma_find_gid(struct ib_device *device,
44 const union ib_gid *gid,
45 enum ib_gid_type gid_type,
46 struct net_device *ndev);
Jason Gunthorpec3d71b62018-06-05 08:40:20 +030047const struct ib_gid_attr *rdma_find_gid_by_port(struct ib_device *ib_dev,
48 const union ib_gid *gid,
49 enum ib_gid_type gid_type,
50 u8 port,
51 struct net_device *ndev);
Jason Gunthorpec3d71b62018-06-05 08:40:20 +030052const struct ib_gid_attr *rdma_find_gid_by_filter(
53 struct ib_device *device, const union ib_gid *gid, u8 port_num,
54 bool (*filter)(const union ib_gid *gid, const struct ib_gid_attr *,
55 void *),
56 void *context);
57
Parav Pandita70c0732019-05-02 10:48:03 +030058int rdma_read_gid_l2_fields(const struct ib_gid_attr *attr,
59 u16 *vlan_id, u8 *smac);
Parav Panditadb4a572019-05-02 10:48:04 +030060struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr);
Parav Pandita70c0732019-05-02 10:48:03 +030061
Matan Barakd300ec52015-10-15 18:38:46 +030062/**
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 * ib_get_cached_pkey - Returns a cached PKey table entry
64 * @device: The device to query.
65 * @port_num: The port number of the device to query.
66 * @index: The index into the cached PKey table to query.
67 * @pkey: The PKey value found at the specified index.
68 *
69 * ib_get_cached_pkey() fetches the specified PKey table entry stored in
70 * the local software cache.
71 */
72int ib_get_cached_pkey(struct ib_device *device_handle,
73 u8 port_num,
74 int index,
75 u16 *pkey);
76
77/**
78 * ib_find_cached_pkey - Returns the PKey table index where a specified
79 * PKey value occurs.
80 * @device: The device to query.
81 * @port_num: The port number of the device to search for the PKey.
82 * @pkey: The PKey value to search for.
83 * @index: The index into the cached PKey table where the PKey was found.
84 *
85 * ib_find_cached_pkey() searches the specified PKey table in
86 * the local software cache.
87 */
88int ib_find_cached_pkey(struct ib_device *device,
89 u8 port_num,
90 u16 pkey,
91 u16 *index);
92
Jack Morgenstein6fb9cdb2006-06-17 20:37:34 -070093/**
Jack Morgenstein73aaa742012-08-03 08:40:39 +000094 * ib_find_exact_cached_pkey - Returns the PKey table index where a specified
95 * PKey value occurs. Comparison uses the FULL 16 bits (incl membership bit)
96 * @device: The device to query.
97 * @port_num: The port number of the device to search for the PKey.
98 * @pkey: The PKey value to search for.
99 * @index: The index into the cached PKey table where the PKey was found.
100 *
101 * ib_find_exact_cached_pkey() searches the specified PKey table in
102 * the local software cache.
103 */
104int ib_find_exact_cached_pkey(struct ib_device *device,
105 u8 port_num,
106 u16 pkey,
107 u16 *index);
108
109/**
Jack Morgenstein6fb9cdb2006-06-17 20:37:34 -0700110 * ib_get_cached_lmc - Returns a cached lmc table entry
111 * @device: The device to query.
112 * @port_num: The port number of the device to query.
113 * @lmc: The lmc value for the specified port for that device.
114 *
115 * ib_get_cached_lmc() fetches the specified lmc table entry stored in
116 * the local software cache.
117 */
118int ib_get_cached_lmc(struct ib_device *device,
119 u8 port_num,
120 u8 *lmc);
121
Jack Wang9e2c3f12017-01-02 13:19:24 +0100122/**
123 * ib_get_cached_port_state - Returns a cached port state table entry
124 * @device: The device to query.
125 * @port_num: The port number of the device to query.
126 * @port_state: port_state for the specified port for that device.
127 *
128 * ib_get_cached_port_state() fetches the specified port_state table entry stored in
129 * the local software cache.
130 */
131int ib_get_cached_port_state(struct ib_device *device,
132 u8 port_num,
133 enum ib_port_state *port_active);
134
Parav Pandit25e62652018-05-22 20:33:45 +0300135bool rdma_is_zero_gid(const union ib_gid *gid);
Parav Panditbf399c22018-06-05 08:40:17 +0300136const struct ib_gid_attr *rdma_get_gid_attr(struct ib_device *device,
137 u8 port_num, int index);
138void rdma_put_gid_attr(const struct ib_gid_attr *attr);
139void rdma_hold_gid_attr(const struct ib_gid_attr *attr);
Jason Gunthorpe7aaa1802018-07-27 09:48:30 -0600140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141#endif /* _IB_CACHE_H */