Loading...
1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2/*
3 * Copyright (c) 2004 Topspin Communications. All rights reserved.
4 * Copyright (c) 2005 Intel Corporation. All rights reserved.
5 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
6 */
7
8#ifndef _IB_CACHE_H
9#define _IB_CACHE_H
10
11#include <rdma/ib_verbs.h>
12
13int rdma_query_gid(struct ib_device *device, u32 port_num, int index,
14 union ib_gid *gid);
15void *rdma_read_gid_hw_context(const struct ib_gid_attr *attr);
16const struct ib_gid_attr *rdma_find_gid(struct ib_device *device,
17 const union ib_gid *gid,
18 enum ib_gid_type gid_type,
19 struct net_device *ndev);
20const struct ib_gid_attr *rdma_find_gid_by_port(struct ib_device *ib_dev,
21 const union ib_gid *gid,
22 enum ib_gid_type gid_type,
23 u32 port,
24 struct net_device *ndev);
25const struct ib_gid_attr *rdma_find_gid_by_filter(
26 struct ib_device *device, const union ib_gid *gid, u32 port_num,
27 bool (*filter)(const union ib_gid *gid, const struct ib_gid_attr *,
28 void *),
29 void *context);
30
31int rdma_read_gid_l2_fields(const struct ib_gid_attr *attr,
32 u16 *vlan_id, u8 *smac);
33struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr);
34
35/**
36 * ib_get_cached_pkey - Returns a cached PKey table entry
37 * @device: The device to query.
38 * @port_num: The port number of the device to query.
39 * @index: The index into the cached PKey table to query.
40 * @pkey: The PKey value found at the specified index.
41 *
42 * ib_get_cached_pkey() fetches the specified PKey table entry stored in
43 * the local software cache.
44 */
45int ib_get_cached_pkey(struct ib_device *device_handle,
46 u32 port_num,
47 int index,
48 u16 *pkey);
49
50/**
51 * ib_find_cached_pkey - Returns the PKey table index where a specified
52 * PKey value occurs.
53 * @device: The device to query.
54 * @port_num: The port number of the device to search for the PKey.
55 * @pkey: The PKey value to search for.
56 * @index: The index into the cached PKey table where the PKey was found.
57 *
58 * ib_find_cached_pkey() searches the specified PKey table in
59 * the local software cache.
60 */
61int ib_find_cached_pkey(struct ib_device *device,
62 u32 port_num,
63 u16 pkey,
64 u16 *index);
65
66/**
67 * ib_find_exact_cached_pkey - Returns the PKey table index where a specified
68 * PKey value occurs. Comparison uses the FULL 16 bits (incl membership bit)
69 * @device: The device to query.
70 * @port_num: The port number of the device to search for the PKey.
71 * @pkey: The PKey value to search for.
72 * @index: The index into the cached PKey table where the PKey was found.
73 *
74 * ib_find_exact_cached_pkey() searches the specified PKey table in
75 * the local software cache.
76 */
77int ib_find_exact_cached_pkey(struct ib_device *device,
78 u32 port_num,
79 u16 pkey,
80 u16 *index);
81
82/**
83 * ib_get_cached_lmc - Returns a cached lmc table entry
84 * @device: The device to query.
85 * @port_num: The port number of the device to query.
86 * @lmc: The lmc value for the specified port for that device.
87 *
88 * ib_get_cached_lmc() fetches the specified lmc table entry stored in
89 * the local software cache.
90 */
91int ib_get_cached_lmc(struct ib_device *device,
92 u32 port_num,
93 u8 *lmc);
94
95/**
96 * ib_get_cached_port_state - Returns a cached port state table entry
97 * @device: The device to query.
98 * @port_num: The port number of the device to query.
99 * @port_state: port_state for the specified port for that device.
100 *
101 * ib_get_cached_port_state() fetches the specified port_state table entry stored in
102 * the local software cache.
103 */
104int ib_get_cached_port_state(struct ib_device *device,
105 u32 port_num,
106 enum ib_port_state *port_active);
107
108bool rdma_is_zero_gid(const union ib_gid *gid);
109const struct ib_gid_attr *rdma_get_gid_attr(struct ib_device *device,
110 u32 port_num, int index);
111void rdma_put_gid_attr(const struct ib_gid_attr *attr);
112void rdma_hold_gid_attr(const struct ib_gid_attr *attr);
113ssize_t rdma_query_gid_table(struct ib_device *device,
114 struct ib_uverbs_gid_entry *entries,
115 size_t max_entries);
116
117#endif /* _IB_CACHE_H */
1/*
2 * Copyright (c) 2004 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Intel Corporation. All rights reserved.
4 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
5 *
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.
33 */
34
35#ifndef _IB_CACHE_H
36#define _IB_CACHE_H
37
38#include <rdma/ib_verbs.h>
39
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.
46 * @attr: The GID attribute found at the specified index (only in RoCE).
47 * NULL means ignore (output parameter).
48 *
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,
55 union ib_gid *gid,
56 struct ib_gid_attr *attr);
57
58int ib_find_cached_gid(struct ib_device *device,
59 const union ib_gid *gid,
60 enum ib_gid_type gid_type,
61 struct net_device *ndev,
62 u8 *port_num,
63 u16 *index);
64
65int ib_find_cached_gid_by_port(struct ib_device *device,
66 const union ib_gid *gid,
67 enum ib_gid_type gid_type,
68 u8 port_num,
69 struct net_device *ndev,
70 u16 *index);
71
72int ib_find_gid_by_filter(struct ib_device *device,
73 const union ib_gid *gid,
74 u8 port_num,
75 bool (*filter)(const union ib_gid *gid,
76 const struct ib_gid_attr *,
77 void *),
78 void *context, u16 *index);
79/**
80 * ib_get_cached_pkey - Returns a cached PKey table entry
81 * @device: The device to query.
82 * @port_num: The port number of the device to query.
83 * @index: The index into the cached PKey table to query.
84 * @pkey: The PKey value found at the specified index.
85 *
86 * ib_get_cached_pkey() fetches the specified PKey table entry stored in
87 * the local software cache.
88 */
89int ib_get_cached_pkey(struct ib_device *device_handle,
90 u8 port_num,
91 int index,
92 u16 *pkey);
93
94/**
95 * ib_find_cached_pkey - Returns the PKey table index where a specified
96 * PKey value occurs.
97 * @device: The device to query.
98 * @port_num: The port number of the device to search for the PKey.
99 * @pkey: The PKey value to search for.
100 * @index: The index into the cached PKey table where the PKey was found.
101 *
102 * ib_find_cached_pkey() searches the specified PKey table in
103 * the local software cache.
104 */
105int ib_find_cached_pkey(struct ib_device *device,
106 u8 port_num,
107 u16 pkey,
108 u16 *index);
109
110/**
111 * ib_find_exact_cached_pkey - Returns the PKey table index where a specified
112 * PKey value occurs. Comparison uses the FULL 16 bits (incl membership bit)
113 * @device: The device to query.
114 * @port_num: The port number of the device to search for the PKey.
115 * @pkey: The PKey value to search for.
116 * @index: The index into the cached PKey table where the PKey was found.
117 *
118 * ib_find_exact_cached_pkey() searches the specified PKey table in
119 * the local software cache.
120 */
121int ib_find_exact_cached_pkey(struct ib_device *device,
122 u8 port_num,
123 u16 pkey,
124 u16 *index);
125
126/**
127 * ib_get_cached_lmc - Returns a cached lmc table entry
128 * @device: The device to query.
129 * @port_num: The port number of the device to query.
130 * @lmc: The lmc value for the specified port for that device.
131 *
132 * ib_get_cached_lmc() fetches the specified lmc table entry stored in
133 * the local software cache.
134 */
135int ib_get_cached_lmc(struct ib_device *device,
136 u8 port_num,
137 u8 *lmc);
138
139/**
140 * ib_get_cached_port_state - Returns a cached port state table entry
141 * @device: The device to query.
142 * @port_num: The port number of the device to query.
143 * @port_state: port_state for the specified port for that device.
144 *
145 * ib_get_cached_port_state() fetches the specified port_state table entry stored in
146 * the local software cache.
147 */
148int ib_get_cached_port_state(struct ib_device *device,
149 u8 port_num,
150 enum ib_port_state *port_active);
151
152#endif /* _IB_CACHE_H */