blob: 226ae3702d8a8e8ebd05e5cab9ceece3209a82b8 [file] [log] [blame]
Leon Romanovsky6bf9d8f2020-07-19 10:25:21 +03001/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * Copyright (c) 2004 Topspin Communications. All rights reserved.
Roland Dreier2a1d9b72005-08-10 23:03:10 -07004 * Copyright (c) 2005 Intel Corporation. All rights reserved.
5 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
7
8#ifndef _IB_CACHE_H
9#define _IB_CACHE_H
10
Roland Dreiera4d61e82005-08-25 13:40:04 -070011#include <rdma/ib_verbs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
Mark Bloch1fb7f892021-03-01 09:04:20 +020013int rdma_query_gid(struct ib_device *device, u32 port_num, int index,
Jason Gunthorpec3d71b62018-06-05 08:40:20 +030014 union ib_gid *gid);
Selvin Xavier779820c2020-02-19 02:19:53 -080015void *rdma_read_gid_hw_context(const struct ib_gid_attr *attr);
Jason Gunthorpec3d71b62018-06-05 08:40:20 +030016const 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);
Jason Gunthorpec3d71b62018-06-05 08:40:20 +030020const 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,
Mark Bloch1fb7f892021-03-01 09:04:20 +020023 u32 port,
Jason Gunthorpec3d71b62018-06-05 08:40:20 +030024 struct net_device *ndev);
Jason Gunthorpec3d71b62018-06-05 08:40:20 +030025const struct ib_gid_attr *rdma_find_gid_by_filter(
Mark Bloch1fb7f892021-03-01 09:04:20 +020026 struct ib_device *device, const union ib_gid *gid, u32 port_num,
Jason Gunthorpec3d71b62018-06-05 08:40:20 +030027 bool (*filter)(const union ib_gid *gid, const struct ib_gid_attr *,
28 void *),
29 void *context);
30
Parav Pandita70c0732019-05-02 10:48:03 +030031int rdma_read_gid_l2_fields(const struct ib_gid_attr *attr,
32 u16 *vlan_id, u8 *smac);
Parav Panditadb4a572019-05-02 10:48:04 +030033struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr);
Parav Pandita70c0732019-05-02 10:48:03 +030034
Matan Barakd300ec52015-10-15 18:38:46 +030035/**
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 * 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,
Mark Bloch1fb7f892021-03-01 09:04:20 +020046 u32 port_num,
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 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,
Mark Bloch1fb7f892021-03-01 09:04:20 +020062 u32 port_num,
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 u16 pkey,
64 u16 *index);
65
Jack Morgenstein6fb9cdb2006-06-17 20:37:34 -070066/**
Jack Morgenstein73aaa742012-08-03 08:40:39 +000067 * 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,
Mark Bloch1fb7f892021-03-01 09:04:20 +020078 u32 port_num,
Jack Morgenstein73aaa742012-08-03 08:40:39 +000079 u16 pkey,
80 u16 *index);
81
82/**
Jack Morgenstein6fb9cdb2006-06-17 20:37:34 -070083 * 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,
Mark Bloch1fb7f892021-03-01 09:04:20 +020092 u32 port_num,
Jack Morgenstein6fb9cdb2006-06-17 20:37:34 -070093 u8 *lmc);
94
Jack Wang9e2c3f12017-01-02 13:19:24 +010095/**
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,
Mark Bloch1fb7f892021-03-01 09:04:20 +0200105 u32 port_num,
Jack Wang9e2c3f12017-01-02 13:19:24 +0100106 enum ib_port_state *port_active);
107
Parav Pandit25e62652018-05-22 20:33:45 +0300108bool rdma_is_zero_gid(const union ib_gid *gid);
Parav Panditbf399c22018-06-05 08:40:17 +0300109const struct ib_gid_attr *rdma_get_gid_attr(struct ib_device *device,
Mark Bloch1fb7f892021-03-01 09:04:20 +0200110 u32 port_num, int index);
Parav Panditbf399c22018-06-05 08:40:17 +0300111void rdma_put_gid_attr(const struct ib_gid_attr *attr);
112void rdma_hold_gid_attr(const struct ib_gid_attr *attr);
Avihai Horonc4b4d542020-09-23 19:50:14 +0300113ssize_t rdma_query_gid_table(struct ib_device *device,
114 struct ib_uverbs_gid_entry *entries,
115 size_t max_entries);
Jason Gunthorpe7aaa1802018-07-27 09:48:30 -0600116
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117#endif /* _IB_CACHE_H */